A queue using mongo as backend storage.
Project description
mongo-mq
Simple job queue using mongodb
Usage
A queue can be instantiated with a mongo collection and a consumer identifier. The consumer identifier helps distinguish multiple queue consumers that are taking jobs from the queue:
>> from pymongo import MongoClient >> from mongomq import MongoQueue >> queue = MongoQueue( ... MongoClient().test.doctest_queu, ... consumer_id="consumer-1", ... timeout=300, ... max_attempts=3, ... ttl=18000)
You can set ttl in seconds, after this time the job will be delete from database (default 5 hours)
New jobs/items can be placed in the queue by passing a dictionary:
>> queue.put({"foobar": 1})
A job priority key and integer value can be specified in the dictionary which will cause the job to be processed before lower priority items:
>> queue.put({"foobar": 0}, priority=1})
An item can be fetched out by calling the next method on a queue. This returns a Job object:
>> job = queue.next() >> job.payload {"foobar": 1} >> job.status 'started'
Inspired By
Running Tests
Unit tests can be run with
$ python setup.py nosetests
Credits
Zaytsev Dmitriy, maintainer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file mongo-mq-0.0.1.tar.gz
.
File metadata
- Download URL: mongo-mq-0.0.1.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 647284ea1467f1054b01961ce769244562bce77f6ee4d6e2486936e5de1afd93 |
|
MD5 | 322602f0fc6b1356b6284179e1cf8517 |
|
BLAKE2b-256 | cb3a4957ec3bdc4aaec8f3c6da73665614ca31c34682f7bb1b49af53d2cafb11 |