Git Product home page Git Product logo

aiodisque's Introduction

AIO Disque

Python3.5 & Asyncio client for Disque message broker.

Sources are available at https://lab.errorist.xyz/aio/aiodisque, and mirrored at https://github.com/johnnoone/aiodisque.

Installation

aiodisque requires a running disque server.

python -m pip install -e .

Getting started

Usage:

from aiodisque import Disque
client = Disque()
job_id = await client.sendjob('queue', 'body')

client accepts a tcp or unix address:

client = Disque(address='127.0.0.1:7711')
client = Disque(address=('127.0.0.1', 7711))
client = Disque(address='/path/to/socket')

API Reference

The official Disque command documentation does a great job of explaining each command in detail. There are a few exceptions:

  • each method are lowered
  • async keywords are replaced by asynchronous

In addition to the changes above, it implements some async sugar:

  • Fancy async iterators:

    async for jobs in client.client.getjob_iter('q', nohang=True):
        print(jobs)
    
    async for queue in client.qscan_iter(count=128):
        print(queue)
    
    async for job in client.jscan_iter(count=128):
        print(job)
  • There is also an experimentaton that try to mimic an asyncio.Queue:

    from aiodisque.queue import Queue
    queue = JobsQueue('queue', client)
    job_id = await queue.put('job')
    job = await queue.get()
    assert job.id == job_id
  • client can reconnect automatically when a connection lost:

    from aiodisque import Disque
    client = Disque(auto_reconnect=True)
    await client.hello()
    # ... connection has been lost here...
    await client.hello()  # this not fails

For more details about the python implementation, you can consult the AIO Disque documentation.

TODO

  • use state object instead of str for pause.
  • more tests for qstat.
  • handle -PAUSED errors and None queues (qstat).
  • document pur python/asyncio feature.

aiodisque's People

Contributors

dm-xba avatar johnnoone avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.