MongoDB plugging for pynenc, a distributed task queue for Python.
Project description
Pynenc MongoDB Plugin
Full-stack MongoDB backend for Pynenc distributed task orchestration
Documentation: https://pynenc-mongodb.readthedocs.io
Pynenc Documentation: https://docs.pynenc.org
Source Code: https://github.com/pynenc/pynenc-mongodb
The pynenc-mongo plugin provides all five Pynenc backend components running on MongoDB, with automatic document chunking for large payloads and a pseudo-atomic ownership protocol for distributed invocation management.
Components
| Component | Class | Role |
|---|---|---|
| Orchestrator | MongoOrchestrator |
Invocation lifecycle, ownership consensus & blocking control |
| Broker | MongoBroker |
FIFO message queue using MongoDB collections |
| State Backend | MongoStateBackend |
Persistent state, results & exceptions with auto document chunking |
| Client Data Store | MongoClientDataStore |
Argument caching with compression for large payloads |
| Trigger | MongoTrigger |
Event-driven & cron-based scheduling with distributed claims |
Installation
pip install pynenc-mongo
The plugin registers itself automatically via Python entry points when installed.
Quick Start
from pynenc import PynencBuilder
app = (
PynencBuilder()
.app_id("my_app")
.mongo(url="mongodb://localhost:27017/pynenc") # all components on MongoDB
.process_runner()
.build()
)
@app.task
def add(x: int, y: int) -> int:
return x + y
result = add(1, 2).result # 3
.mongo() registers every component at once. Start a runner with:
pynenc --app=tasks.app runner start
Configuration
Builder Parameters
# URL-based (recommended)
app = (
PynencBuilder()
.app_id("my_app")
.mongo(url="mongodb://localhost:27017/pynenc")
.multi_thread_runner(min_threads=2, max_threads=8)
.build()
)
# Individual parameters
app = (
PynencBuilder()
.app_id("my_app")
.mongo(
host="localhost",
port=27017,
db="pynenc",
username="admin",
password="secret",
auth_source="admin",
)
.process_runner()
.build()
)
Component-Specific Configuration
app = (
PynencBuilder()
.app_id("my_app")
.mongo(url="mongodb://localhost:27017/pynenc")
.mongo_client_data_store(
min_size_to_cache=1024, # cache arguments > 1KB
local_cache_size=1000, # local LRU cache entries
max_size_to_cache=16777216, # max 16MB per document
)
.mongo_trigger(
scheduler_interval_seconds=60,
enable_scheduler=True,
)
.build()
)
Environment Variables
PYNENC__MONGO__MONGO_URL="mongodb://localhost:27017/pynenc"
# Or individual parameters:
PYNENC__MONGO__MONGO_HOST="localhost"
PYNENC__MONGO__MONGO_PORT=27017
PYNENC__MONGO__MONGO_DB="pynenc"
Connection URLs
.mongo(url="mongodb://localhost:27017/pynenc") # Standard
.mongo(url="mongodb://user:pass@localhost:27017/pynenc?authSource=admin") # With auth
.mongo(url="mongodb+srv://cluster.example.net/pynenc") # Atlas SRV
Requirements
- Python >= 3.11
- Pynenc >= 0.1.0
- pymongo >= 3.12.2
- A running MongoDB server
Related Plugins
- pynenc-redis: Full-stack Redis backend
- pynenc-rabbitmq: RabbitMQ broker (pairs with MongoDB for state/orchestrator/triggers)
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pynenc_mongo-0.1.7.tar.gz.
File metadata
- Download URL: pynenc_mongo-0.1.7.tar.gz
- Upload date:
- Size: 451.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d6805f5a5a554973a893f1182bb9796f28c7f9c35ff88488bee9547c6ae487b
|
|
| MD5 |
2b0db01fe4f7ee34e1b82a91e404b63a
|
|
| BLAKE2b-256 |
3981781e0fe003366df06aef67ab6ad72b4c5637f6a4a7007e3f9d0ccb33e24d
|
File details
Details for the file pynenc_mongo-0.1.7-py3-none-any.whl.
File metadata
- Download URL: pynenc_mongo-0.1.7-py3-none-any.whl
- Upload date:
- Size: 40.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df38d0caa5c70369fd579fdbab0379ffca1bad4392257bfd657ab123e968547e
|
|
| MD5 |
9a28cbd4c0c8ce707231bc78719618e9
|
|
| BLAKE2b-256 |
72ec16483da77516934fa7176a24eb0ca368b8711393f5fe94f9153dbec60c9d
|