Skip to main content

Queueing data structure on top of a MongoDB collection

Project description

Mongo TaskQueue

Python 3.6 PyPI version MongoDB

Mongo-TaskQueue is a queueing data structure built on top of a MongoDB collection.

Quick start

Just create an instance of TaskQueue and start to append to your queue:

>>> from mongotq import get_task_queue

>>> task_queue = get_task_queue(
        database_name=YOUR_MONGO_DATABASE_NAME,
        collection_name='queueGeocoding',
        host=YOUR_MONGO_DB_URI,
        ttl=-1  # permanent queue
    )
>>> task_queue.append({'species': 'Great Horned Owl'})
>>> task_queue.append({'species': 'Eastern Screech Owl'})
>>> task_queue.append({'species': 'Northern Saw-whet Owl'})
>>> task_queue.append({'species': 'Snowy Owl'})
>>> task_queue.append({'species': 'Whiskered Screech Owl'})

Then you can simply check the tail of your queue:

>>> task_queue.tail(n=5)
{'_id': ObjectId('6392375588c63227371c693c'),
 'assignedTo': None,
 'createdAt': datetime.datetime(2022, 12, 8, 14, 13, 25, 99685),
 'errorMessage': None,
 'modifiedAt': datetime.datetime(2022, 12, 8, 14, 13, 25, 99685),
 'payload': {'species': 'Great Horned Owl'},
 'priority': 0,
 'retries': 0,
 'status': 'new'}
{'_id': ObjectId('6392375588c63227371c693d'),
 'assignedTo': None,
 'createdAt': datetime.datetime(2022, 12, 8, 14, 13, 25, 129570),
 'errorMessage': None,
 'modifiedAt': datetime.datetime(2022, 12, 8, 14, 13, 25, 129570),
 'payload': {'species': 'Eastern Screech Owl'},
 'priority': 0,
 'retries': 0,
 'status': 'new'}
{'_id': ObjectId('6392375588c63227371c693e'),
 'assignedTo': None,
 'createdAt': datetime.datetime(2022, 12, 8, 14, 13, 25, 155404),
 'errorMessage': None,
 'modifiedAt': datetime.datetime(2022, 12, 8, 14, 13, 25, 155404),
 'payload': {'species': 'Northern Saw-whet Owl'},
 'priority': 0,
 'retries': 0,
 'status': 'new'}
{'_id': ObjectId('6392375588c63227371c693f'),
 'assignedTo': None,
 'createdAt': datetime.datetime(2022, 12, 8, 14, 13, 25, 179804),
 'errorMessage': None,
 'modifiedAt': datetime.datetime(2022, 12, 8, 14, 13, 25, 179804),
 'payload': {'species': 'Snowy Owl'},
 'priority': 0,
 'retries': 0,
 'status': 'new'}
{'_id': ObjectId('6392375588c63227371c6940'),
 'assignedTo': None,
 'createdAt': datetime.datetime(2022, 12, 8, 14, 13, 25, 204284),
 'errorMessage': None,
 'modifiedAt': datetime.datetime(2022, 12, 8, 14, 13, 25, 204284),
 'payload': {'species': 'Whiskered Screech Owl'},
 'priority': 0,
 'retries': 0,
 'status': 'new'}
5 Task(s) available in the TaskQueue

Installation

The only dependency is pyMongo. The easiest way to install Mongo-TaskQueue is using pip:

pip install mongo-taskqueue

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

mongo-taskqueue-0.2.4.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

mongo_taskqueue-0.2.4-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file mongo-taskqueue-0.2.4.tar.gz.

File metadata

  • Download URL: mongo-taskqueue-0.2.4.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for mongo-taskqueue-0.2.4.tar.gz
Algorithm Hash digest
SHA256 3e3f7551a3526fdf694fd60b9bcba66de3f3a6700387e2c06e4544170f4424d1
MD5 8c4f10b3a24882b71b0463afd3b63575
BLAKE2b-256 41b91f6de18e6ab82bfdb1132fbbd4644d8ae99a4f2fb14f168afdb6b3e2cef2

See more details on using hashes here.

File details

Details for the file mongo_taskqueue-0.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for mongo_taskqueue-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 737541722a2459039d189b657409aa283bd6022a5f027c58d3c0f7da573577cc
MD5 31faa7c28afcd9fa7441568776eb3d02
BLAKE2b-256 6388d3bf370a6bcd9efbe3de69d1b84fb4644948a39cf084a249d4dd8e7505b9

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