asyncio client and server for RQ.
- Event loop friendly
- Non-blocking job enqueueing and result obtaining
You can always install last released version from python package index.
pip install aiorq
Suppose we have a module with slow blocking function like this one.
import requests
def get_json(url):
response = requests.get(url)
return response.json()
To schedule deferred jobs create queue and enqueue the function call within event loop.
import asyncio
from aioredis import create_redis
from aiorq import Queue
from my_module import get_json
loop = asyncio.get_event_loop()
@asyncio.coroutine
def main():
redis = yield from create_redis(('localhost', 6379), loop=loop)
queue = Queue(connection=redis)
job = yield from queue.enqueue(get_json, 'https://www.python.org')
print((yield from job.result))
redis.close()
yield from redis.wait_closed()
loop.run_until_complete(main())
The aiorq is offered under LGPL license.