Skip to main content

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

Metadata

Release files for mongo-mq 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mongo-mq 0.0.1
File Size Uploaded
mongo-mq-0.0.1.tar.gz 5.4 kB Details

Release files / mongo-mq-0.0.1.tar.gz

Download URL mongo-mq-0.0.1.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
647284ea1467f1054b01961ce769244562bce77f6ee4d6e2486936e5de1afd93
BLAKE2b-256 checksum
How to use checksums
cb3a4957ec3bdc4aaec8f3c6da73665614ca31c34682f7bb1b49af53d2cafb11
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page