Skip to main content

MongoDB plugging for pynenc, a distributed task queue for Python.

Project description

Pynenc

Pynenc MongoDB Plugin

Full-stack MongoDB backend for Pynenc distributed task orchestration

Package version Supported Python versions GitHub last commit GitHub license


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.12
  • Pynenc >= 0.3.0
  • pymongo >= 3.12.2
  • A running MongoDB server

Related Plugins

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

pynenc_mongo-0.3.0.tar.gz (447.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynenc_mongo-0.3.0-py3-none-any.whl (45.2 kB view details)

Uploaded Python 3

File details

Details for the file pynenc_mongo-0.3.0.tar.gz.

File metadata

  • Download URL: pynenc_mongo-0.3.0.tar.gz
  • Upload date:
  • Size: 447.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for pynenc_mongo-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b8f372b5150417540c7d9c6e40d1005bede02db946e8345bc0c82b06c5f600bd
MD5 319a6c6a753ae3fcdb96218d4ca485b9
BLAKE2b-256 181eb2fe4c20e3026f12f6f2299dea22e4c49045502e05edfc089171022968b6

See more details on using hashes here.

File details

Details for the file pynenc_mongo-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pynenc_mongo-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 45.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for pynenc_mongo-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9950ccd1837bdf78e1cdbc3178a25c076b9d53743fbca2ae06c6755e5a67ea8
MD5 52872b1140d78f03998a00ce74b545d6
BLAKE2b-256 31470c1b78ceca96621996441ba585a1f766a27be649d3b9991b2694e9e665aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page