Skip to main content

aiohttp client workers with redis in/out queues

Project description

Installation

$ pip install aiohttp-rq

Environment variables

Variable default
AIOHTTP_RQ_DIR None
AIOHTTP_RQ_REQUEST_QUEUE aiohttp-rq-request
AIOHTTP_RQ_RESPONSE_QUEUE aiohttp-rq-response
AIOHTTP_RQ_EXCEPTION_QUEUE aiohttp-rq-exception

optional

Variable default
AIOHTTP_RQ_LOG_CONFIG_FILE None
AIOHTTP_RQ_TTL_DNS_CACHE 10
REDIS_HOST localhost
REDIS_PORT 6379
REDIS_DB 0

Features

  • logging
    • DEBUG, ERROR level messages
    • logging.conf support: AIOHTTP_RQ_LOG_CONFIG_FILE
  • request data: method,url, headers, data,allow_redirects, custom arguments
  • response data: url, status, headers,content_path, request_xxx arguments
  • request exception data: url, exc_class, exc_message, request_xxx arguments

Examples

$ export AIOHTTP_RQ_REQUEST_QUEUE="aiohttp-rq-request"
$ export AIOHTTP_RQ_RESPONSE_QUEUE="aiohttp-rq-response"
$ export AIOHTTP_RQ_EXCEPTION_QUEUE="aiohttp-rq-exception"
$ export AIOHTTP_RQ_TTL_DNS_CACHE=3600 # optional
$ python3 -m aiohttp_rq 50 # 50 workers

redis client

import redis

REDIS = redis.Redis(host='localhost', port=6379, db=0)

Redis push

value=json.dumps(dict(
    url='https://domain.com',
    method="GET",
    headers=None,
    data=None,
    allow_redirects=True
))
REDIS.rpush('aiohttp-rq-request',*values)

Redis pull

item_list = REDIS.lrange('aiohttp-rq-response',0,-1)
for item in item_list:
    data = json.loads(item.encode('utf-8'))

item_list = REDIS.lrange('aiohttp-rq-exception',0,-1)
for item in item_list:
    data = json.loads(item.encode('utf-8'))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiohttp_rq-0.0.7.tar.gz (3.6 kB view details)

Uploaded Source

File details

Details for the file aiohttp_rq-0.0.7.tar.gz.

File metadata

  • Download URL: aiohttp_rq-0.0.7.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for aiohttp_rq-0.0.7.tar.gz
Algorithm Hash digest
SHA256 7e20a68fab520b245ad92ed2899a375bc321d77f45630cf8fbf8c2f4508ac78f
MD5 e6effed9c0bb53aaafb350e7faec364d
BLAKE2b-256 4b82da55db9e82dd873ba0ff9321d609d2ecd0e390c24927e69e3d80b952c9d8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page