mongo_queue
Task queue built on mongo with channels and unique job id.
Website • autobotAI Automation Platform
Inspired from kapilt/mongoqueue
Change Log:
v0.0.5
- Added depends_on feature. You can create dependency between jobs by supplying depends_on[] with previously created job ids.
v0.0.3
- Added unique index with job_id and channel. This is to make sure that the same job is not added multiple times. If not job id provided an unique id generated by default.
Usage
Install the package.
pip install mongo_queue
Usage Example:
- Create Queue Object
from mongo_queue.queue import Queue
from pymongo import MongoClient
queue = Queue(MongoClient('localhost', 27017).task_queue, consumer_id="consumer-1", timeout=300, max_attempts=3)
- Add task to queue default channel
queue.put({"task_id": 1})
- Add task to queue with priority to default channel
queue.put({"task_id": 1}, priority=1)
- Add task to queue in a specific channel
queue.put({"task_id": 1}, priority=1, channel="channel_1")
- Add task to queue with unique job_id
queue.put({"task_id": 1}, priority=1, channel="channel_1", job_id="x_job")
- Add task with dependency
job1 = queue.put({"task_id": 1}, priority=1, channel="channel_1", job_id="x_job")
job2 = queue.put({"task_id": 2}, priority=1, channel="channel_1", job_id="x_job", depends_on=[job1])
- Get the next job to be executed from the default channel
job = queue.next()
- Get the next job to be executed from a specific channel
job = queue.next(channel="channel_1")
- Update job progress for long-running jobs
job.progress(count=10)
- Put the job back in queue, this will be picked up again later, this will update attempts after max attempts the job will not be picked up again.
job.release()
- Put the job back in queue with error, this will be picked up again later, this will update attempts after max attempts the job will not be picked up again.
job.error("Some error occured")
- Complete the job. This will delete job from the database.
job.complete()
Build Steps
# Setup venv of python version 3.6 and above
pip install -r requirements.txt
python -m pip install --upgrade twine
python setup.py sdist bdist_wheel
python -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
Metadata
Release files for mongo-queue-service 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mongo_queue_service-0.0.5.tar.gz | 8.3 kB | Without provenance | Details for mongo_queue_service-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mongo_queue_service-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for mongo_queue_service-0.0.5-py3-none-any.whl |
Total release size: 16.9 kB
Release files / mongo_queue_service-0.0.5.tar.gz
| Download URL | mongo_queue_service-0.0.5.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f153b30ec38babc5898f351783dbd4292be46922ec4722e92655998793203b5
|
|
BLAKE2b-256 checksum How to use checksums |
427ad87e8028d9f72caf8966faa1b2ef901918262513e77419b873164fc15747
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9
|
Release files / mongo_queue_service-0.0.5-py3-none-any.whl
| Download URL | mongo_queue_service-0.0.5-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b299d91f7c144417a38dc7e46aff97f0b22b06e891c3c151de4df1dcd9adea5
|
|
BLAKE2b-256 checksum How to use checksums |
98de0206a9685307072e395cc211ba4c34fe53e542ffa51178a7b7103d8369ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9
|
Security for mongo-queue-service 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.