Skip to content

CodersOfTheNight/aiorq

Repository files navigation

aiorq

Build Status Coverage Status Requirements Status Code Quality Status Python Package Version

asyncio client and server for RQ.

Features

  • Event loop friendly
  • Non-blocking job enqueueing and result obtaining

Installation

You can always install last released version from python package index.

pip install aiorq

Getting started

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())

License

The aiorq is offered under LGPL license.

About

asyncio client and server for RQ.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages