Skip to main content

disque client

Project description

pydisque

Client for Disque, an in-memory, distributed job queue.

Build Status

Documentation

Read The Docs

Usage

Create a new Disque client by passing a list of nodes:

from pydisque.client import Client
client = Client(["127.0.0.1:7711", "127.0.0.1:7712", "127.0.0.1:7713"])
client.connect()

If it can't connect to first node, it will try to connect to second, etc.., if it can't connect to any node, it will raise a redis.exceptions.ConnectionError as you can imagine.

Now you can add jobs:

client.add_job("test_queue", json.dumps(["print", "hello", "world", time.time()]), timeout=100)

It will push the job "print" to the queue "test_queue" with a timeout of 100 ms, and return the id of the job if it was received and replicated in time. If it can't reach the node - maybe it was shutdown etc. - it will retry to connect to another node in given node list, and then send the job. If there is no avail nodes in your node list, it will obviously raise a ConnectionError

Then, your workers will do something like this:

while True:
    jobs = client.get_job(['test_queue'])
    for queue_name, job_id, job in jobs:
        job = json.loads(job)
        print ">>> received job:", job
        client.ack_job(job_id)

also check examples directory.

While waiting jobs your connected node may go down, pydisque will try to connect to next node, so you can restart your nodes without taking down your clients.

Documentation

For now please check docstrings in disque/client.py, implemented commands are

  • info
  • add_job
  • get_job
  • ack_job
  • nack_job
  • fast_ack
  • working
  • qlen
  • qstat
  • qpeek
  • qscan
  • jscan
  • enqueue
  • dequeue
  • del_job
  • show
  • pause
  • hello

Installation

You can install it using pip.

$ pip install pydisque

License

This project is licensed under the terms of the MIT license

Credits

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

pydisque-0.1.5.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

pydisque-0.1.5-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file pydisque-0.1.5.tar.gz.

File metadata

  • Download URL: pydisque-0.1.5.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for pydisque-0.1.5.tar.gz
Algorithm Hash digest
SHA256 35517b43afe5d675586956de0f919ad3b82b1be6047319009906bcaafd4b60f9
MD5 5a8522a5cda061bee71bb83149e95e97
BLAKE2b-256 d0bee9334062fef8ee4d41c0730aab811139bfb94ea83d2774879fa4b9d40774

See more details on using hashes here.

File details

Details for the file pydisque-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: pydisque-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for pydisque-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9d7a9ea8c4d335fb8d217d002683b46b6450b6b4a0c421c39a699090b4f7dbc8
MD5 1c78ca6016cffd3f53d9fca82f2fa697
BLAKE2b-256 48d6a520a561d7e340a2746e5f20bc7311fecedce941579aea066955f6c14faf

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