Skip to main content

z4j-celery

PyPI version Python License

The Celery engine adapter for z4j.

Streams supported task lifecycle events from your Celery workers to the z4j brain and accepts operator control actions from the dashboard. Pair with z4j-celerybeat to manage periodic / cron schedules.

Compatibility

  • Celery 5.2.2+ (no upper cap)
  • Python 3.11+

Full per-adapter matrix at https://docs.z4j.com/reference/compatibility/.

What it ships

Capability Notes
Task lifecycle events received, started, succeeded, failed, retried, revoked
Task discovery runtime registry merge + static tasks.py scan
Submit / retry / cancel direct against the Celery app
Bulk retry retries brain-selected explicit task IDs individually; does not sweep the broker
Purge queue with confirm-token guard
Requeue dead-letter unsupported: broker-specific atomic consume/ack and routing are required
Restart worker fire-and-forget pool_restart; requires Celery's worker_pool_restarts setting and operator verification
Pool grow / shrink via Celery's control API
Rate limit fire-and-forget Celery remote-control broadcast to the selected worker(s)
Reconcile task via the result backend

The widest feature coverage of any z4j engine adapter, Celery's remote-control surface provides controls other engines cannot expose. Worker-control broadcasts do not acknowledge execution: verify the worker state afterward. pool_restart is intended for prefork deployments; Celery's gevent and eventlet pools do not support it reliably.

Install

pip install z4j-celery z4j-celerybeat

Pair with a framework adapter:

pip install z4j-django  z4j-celery z4j-celerybeat   # Django
pip install z4j-flask   z4j-celery z4j-celerybeat   # Flask
pip install z4j-fastapi z4j-celery z4j-celerybeat   # FastAPI
pip install z4j-bare    z4j-celery z4j-celerybeat   # framework-free worker

Pairs with

  • z4j-celerybeat, schedule adapter for Celery Beat / django-celery-beat

Retry prerequisites

Retry uses original arguments from Celery's result backend when available. Enable result_extended=True (CELERY_RESULT_EXTENDED=True with Django's CELERY namespace) to store them, and configure a result backend. Those original values are stored outside z4j's redaction layer; apply the backend's access and retention controls. If arguments are unavailable, provide both args and kwargs explicitly. The adapter refuses to replay a task using incomplete or redacted arguments.

Reliability

  • Lifecycle-capture failures are isolated from Celery workers and signal handlers; capture hooks make no brain network request inline.
  • The in-process event queue and SQLite outbound buffer are bounded. A full queue evicts its oldest queued event to admit the new one, up to three times. Queue overflow drops new events only if that cannot make room. Buffer pressure evicts oldest rows. Every loss is logged.

Prefork pools that recycle children

The in-worker agent starts on worker_ready, after the pool forks its first children. A pool that recycles children (--max-tasks-per-child, --max-memory-per-child, or a child lost to a crash or a time limit) keeps forking replacements while the agent's threads run in the worker's main process. Before a replacement reports ready, kombu closes every connection in Celery's shared broker pool, and on Redis, closing a channel that is still waiting on a BRPOP reads from the socket the child shares with the main process.

Earlier releases of the agent waited for control.inspect replies on a pooled connection during the periodic health refresh. One reply wait that timed out, or whose reply a replacement child read first, left the pool in that state. From then on every replacement blocked before reporting ready: the worker log fills with Timed out waiting for UP message and the worker takes no tasks until it is restarted. The agent now waits for broker replies only on connections it opens and closes itself, with a 10 second Redis read timeout unless broker_transport_options sets socket_timeout. The worker log notes at startup when the pool recycles children.

If replacement children still time out with z4j installed, set Z4J_DISABLED=1 on the worker to rule the agent out, and capture py-spy dump --pid <pid> of a child that is waiting to come up (raise Celery's worker_proc_alive_timeout so it lives long enough to inspect).

Documentation

Full docs at docs.z4j.com/engines/celery/.

License

Apache-2.0, see LICENSE.

Metadata

Release files for z4j-celery 1.13.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 z4j-celery 1.13.1
File Size Uploaded Provenance Actions
z4j_celery-1.13.1.tar.gz 89.7 kB Without provenance Details for z4j_celery-1.13.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for z4j-celery 1.13.1
File Interpreter ABI Platform Actions
z4j_celery-1.13.1-py3-none-any.whl Python 3 none any Details for z4j_celery-1.13.1-py3-none-any.whl

Total release size: 164.2 kB

Release files / z4j_celery-1.13.1.tar.gz

Download URL z4j_celery-1.13.1.tar.gz
Size 89.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a470e066771897d15e52cd4c7a5a93a6550fbdd34c0a71d152aff63369f5e8b7
BLAKE2b-256 checksum
How to use checksums
cf128be6d254fc8aae497b471be634f2af2ee206695a97ae0b09570e8cb7eafe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / z4j_celery-1.13.1-py3-none-any.whl

Download URL z4j_celery-1.13.1-py3-none-any.whl
Size 74.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d38f76aec2fe38dcef082cffea81306cf4af3b93d794f37482d78d0179fe84f
BLAKE2b-256 checksum
How to use checksums
2f27dcccc6bb1fb4c29d65165e654c64761ac3e4516a1529ca82cdbccb667d21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for z4j-celery 1.13.1

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.

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