Skip to content

v5.7.0

Latest

Choose a tag to compare

@auvipy auvipy released this 05 Nov 15:12
· 8 commits to main since this release
6fcdbf9

Celery 5.7.0

We're pleased to announce Celery 5.7.0, a new stable release of Celery.

This release brings substantial improvements to task workflows, worker reliability, result handling, scheduling, and broker connectivity. It also includes new integrations, improved Python compatibility, performance optimizations, and a large number of bug fixes contributed by the community.

A significant part of this release focuses on making complex Canvas workflows more reliable and efficient, improving worker behavior during broker disconnections and shutdown, and making result-backend state handling more consistent.

Highlights

  • More reliable Canvas workflows: Improved chains, groups, chords, nested workflows, callbacks, errbacks, and failure propagation. Several fixes also reduce unnecessary message growth in complex chains and chords.
  • Improved worker reliability: Better connection recovery, graceful shutdown, prefork process management, autoscaling, and handling of worker-process loss.
  • More predictable task results: Improved result-state consistency, retry handling, ignore_result behavior, and concurrent AsyncResult tracking.
  • Timezone and scheduling improvements: More reliable ETA, countdown, expiration, crontab, solar schedules, and Celery Beat behavior across daylight-saving-time transitions.
  • New Pydantic integration behavior: Tasks configured with pydantic=True can accept Pydantic model instances.
  • New pymemcache result backend support: Adds support for using pymemcache as a result backend.
  • Improved Redis result backend: New expiration settings for chord and failure results, improved Pub/Sub handling, and more reliable chord accounting.
  • Better Python compatibility: Python 3.10 is now the minimum supported version, with compatibility work for newer Python versions, including Python 3.14.
  • Improved worker operations: Cgroup-aware automatic concurrency detection and additional worker-management improvements.

What's New

Canvas, Chains, Groups, and Chords

Celery 5.7 includes extensive improvements to Canvas execution and composition, particularly for nested workflows and complex chains and chords.

  • Fixed failure propagation through chained tasks into chord bodies.
  • Improved chord failure handling when a chord header or a chained chord fails.
  • Fixed chord error handling when the chord body is itself a chain.
  • Improved handling of empty groups and chains, including empty groups inside chains and group headers.
  • Chains are now constructed in a single pass instead of repeatedly folding signatures with the | operator.
  • Reduced unnecessary message growth in chains of chords, chains of groups, implicit chords, and standalone chord bodies.
  • Improved nested group handling and preservation of group IDs.
  • Fixed duplicate nodes in GroupResult.as_tuple() after groups in chains.
  • Improved GroupResult fan-out behavior in chains.
  • Fixed eager execution behavior for chains containing Ignore or Reject.
  • Avoided unnecessary result-backend access when eagerly applying groups inside chains.
  • Improved task replacement with chains containing groups, including cases that previously could hang.
  • Improved callback execution when a task is replaced by a chain, ensuring callbacks are not invoked repeatedly.
  • Fixed eager-chain callback behavior so that chain links are dispatched once at the appropriate point.
  • Improved propagation of task options, ETA, and countdown values to chord headers.
  • Corrected the handling of link and link_error options on chords so they are applied to the chord body.
  • Improved errback argument classification and handling of new-style errback calls.
  • Preserved group errback mutability and improved stamped-header merging and revocation.
  • Improved signature cloning and option isolation, preventing cloned signatures from sharing mutable keyword arguments with their originals.
  • Fixed argument forwarding through nested chains during eager execution.
  • Improved map and starmap option merging.

These changes make complex Canvas compositions more predictable and reduce unnecessary broker traffic and message growth.

Worker Reliability and Process Management

This release includes a broad set of improvements to worker lifecycle management, process pools, connection recovery, and shutdown behavior.

  • Added support for the spawn start method with the asynchronous prefork pool.
  • Improved detection and initialization of spawned pool children.
  • Added cgroup-aware automatic worker concurrency detection through --concurrency=auto.
  • Added task_retry_on_worker_lost to control task requeues after a worker process is lost.
  • Improved prefork shutdown handling, including draining child results and acknowledging tasks during shutdown.
  • Fixed warm-shutdown issues with Eventlet and thread-based worker pools.
  • Improved cancellation and handling of prefetched tasks during worker shutdown.
  • Fixed worker stalls following broker reconnection.
  • Improved worker connection recovery and graceful shutdown behavior.
  • Fixed issues involving in-flight task reservations and prefetch handling during consumer connection loss.
  • Improved handling of per-consumer QoS and prefetch reduction.
  • Fixed autoscaling and disable-prefetch behavior for green worker pools.
  • Improved autoscale keepalive handling when immediate tasks are received.
  • Improved handling of worker process exit and pool cleanup.
  • Fixed request time-limit handling and ensured task failures are reported when hard time limits are reached.
  • Improved worker shutdown state handling when shutdown logging or signal dispatch raises an exception.
  • Fixed worker initialization and Django integration behavior.
  • Improved worker timer cleanup and broker-reconnection timer handling.
  • Added the worker hostname as the sender for the worker_process_init signal.

These changes improve worker resilience in environments with frequent broker reconnections, process failures, and graceful shutdown requirements.

Task Execution, Publishing, and Acknowledgements

Task publishing and execution behavior received several important correctness improvements.

  • Decoupled acks_on_failure and acks_on_timeout, allowing these acknowledgment behaviors to be configured independently.
  • Improved handling of task acknowledgment and deferred acknowledgment in the worker consumer loop.
  • Improved task execution after ETA conversion failures.
  • Fixed ETA and expiration handling for protocol version 1 messages.
  • Improved handling of task retries and retry argument conflicts.
  • Fixed shared retry_kwargs mutation in automatic retry handling.
  • Improved broker retry behavior when publishing callbacks is refused by the broker.
  • Applied the merged retry policy consistently to task-publishing signals and task-sent events.
  • Fixed task publishing signal dispatch when signal receivers are registered dynamically.
  • Improved handling of per-task serializers and execution options in send_task().
  • Corrected the handling of ignore_result defaults in send_task() and Task.apply().
  • Preserved ignore_result overrides across task retries.
  • Fixed cases where ignored results could incorrectly record RETRY after worker loss.
  • Improved task failure reporting when a worker is lost by preserving request context in task_failure.
  • Improved task state handling when a task has already stored a successful result before a worker is lost.
  • Prevented a task from being marked REVOKED while another worker is still executing it.
  • Improved handling of rejected tasks that are not requeued.
  • Improved task execution and callback behavior when a task is redelivered and result deduplication is enabled.
  • Added runtime information to the task success signal.
  • Improved task request and callback handling around worker loss and memory errors.
  • Improved handling of task names and duplicate task registrations, including a warning when different callables use the same task name.

Result Backends and Result Handling

Result handling has received significant reliability and consistency improvements across several backends.

Redis result backend

  • Added result_chord_expires to control the expiration of chord-related Redis keys.
  • Added result_failure_expires to configure expiration for failure results.
  • Fixed Redis chord accounting so that each chord-header task is counted only once.
  • Improved Redis chord claim cleanup and ownership handling.
  • Improved Redis Pub/Sub synchronization between result draining and result cleanup.
  • Fixed Redis result compression when decode_responses is enabled.
  • Added support for configuring additional Redis connection errors.
  • Improved Redis SSL configuration when using Redis URLs.
  • Improved Redis reconnect and Pub/Sub compatibility across redis-py versions.
  • Added redis-py DriverInfo support.
  • Removed deprecated arguments from Redis connection calls.

Database and other result backends

  • Added support for pymemcache as a result backend.
  • Improved database-backend retry handling across database operations.
  • Added support for database backend retry configuration parameters.
  • Fixed database result serialization to honor result_serializer.
  • Added the missing date_done index to the database backend.
  • Improved database backend handling of SQL engine arguments and connection pooling.
  • Added an engine_callback to the database backend SessionManager.
  • Improved storage of task children and stamping metadata in database-backed extended results.
  • Improved database result cleanup and timezone handling.
  • Added support for preserving the first SUCCESS result in the database, MongoDB, and Cassandra backends.
  • Improved MongoDB result handling when results are stored without a request.
  • Fixed MongoDB result cleanup across daylight-saving-time transitions.
  • Improved Cosmos DB result upsert behavior so subsequent task states can be stored.
  • Improved Couchbase behavior when a result document is missing.
  • Improved idempotency of forget() across supported backends.
  • Improved ArangoDB handling when deleting missing documents.
  • Improved Azure Block Blob backend credential handling and pickling.
  • Improved RPC backend reconnection and result handling.
  • Fixed RPC backend behavior to respect result_extended.
  • Improved result compression and backend cleanup behavior.

AsyncResult and ResultSet

  • Added AsyncResult.exists() to check whether a result exists.
  • Improved backend tracking of multiple AsyncResult instances waiting for the same task ID.
  • Improved ResultSet.add() so results can be added after the set has already become ready.
  • Fixed timeout handling so a timeout of 0 is respected rather than treated as an indefinite wait.
  • Applied the zero-timeout behavior consistently to wait_for, ResultSet.join(), get_many(), and result draining.
  • Improved native result iteration and barrier finalization.
  • Preserved propagation behavior when joining nested native results.
  • Improved eager-result naming behavior when results are copied or pickled.
  • Improved result-state consistency and handling of revoked tasks.

Celery Beat, Scheduling, and Timezones

Celery 5.7 includes extensive fixes to scheduling and timezone handling, especially around daylight-saving-time transitions.

  • Improved ETA, countdown, and expiration calculations across daylight-saving-time transitions.
  • Fixed worker expiration checks during daylight-saving-time fall-back.
  • Improved crontab.remaining_delta() handling for timezone-aware datetimes.
  • Fixed crontab scheduling when later minute slots occur on an earlier day.
  • Improved handling of daylight-saving-time gaps in make_aware().
  • Improved relative schedule rounding across daylight-saving-time transitions.
  • Fixed solar schedule timing across daylight-saving-time changes.
  • Improved handling of non-uniform crontab schedules and beat_cron_starting_deadline.
  • Celery Beat now continues running when an individual schedule entry raises an exception.
  • Improved validation of impossible crontab dates.
  • Fixed Beat heap reordering and sleep behavior when schedule entries change their due time or request a retry.
  • Improved Beat schedule state restoration across persistence cycles.
  • Fixed Beat service serialization and scheduler connection cleanup during shutdown.
  • Added opt-in remote-control inspect ping support to Celery Beat.
  • Added the celery_beat_task header to task options.

These changes improve scheduling correctness and make Beat more resilient when individual scheduled tasks or schedule entries fail.

Queue Management, Routing, and Broker Connectivity

Several improvements were made to queue selection, routing, and broker reconnection behavior.

  • Improved queue alias handling in queue selection and deselection.
  • Fixed queue aliases so the actual queue name is stored when selecting a queue.
  • Improved default queue resolution for explicitly routed tasks.
  • Improved queue configuration so newly added queues receive the default routing key and maximum priority where appropriate.
  • Fixed routing-only queues leaking into worker consumers.
  • Improved restoration of known queues when add_consumer is used.
  • Improved AMQP task-route refresh behavior across configuration update operations.
  • Improved handling of native delayed-delivery bindings, including cycle detection and broadcast queues.
  • Improved RabbitMQ 4.3 compatibility in the RPC result backend and queue handling.
  • Improved worker behavior when unexpected queues are encountered after connection loss.
  • Improved connection recovery and pending-operation ordering.
  • Improved broker connection pool handling by adding a timeout to broker pool acquisition, preventing indefinite blocking.
  • Improved broker retry behavior when purging queues at startup.
  • Improved worker event publishing and buffering during broker reconnections.

Pydantic Integration

Tasks configured with pydantic=True can now accept Pydantic model instances when called.

This improves the integration between Celery tasks and applications that use Pydantic models for data validation and structured task arguments.

Configuration and Application Behavior

  • Improved ConfigurationView behavior so membership checks, key lookups, and iteration respect configuration mapping order.
  • Improved ConfigurationView.swap_with() handling.
  • Improved configuration copying while preserving configured values.
  • Fixed lazy configuration loading to honor config_from_object(silent=True).
  • Improved handling of configuration defaults so preconfigured values are not incorrectly included in defaults.
  • Improved configuration error messages by showing both original and prefixed keys.
  • Fixed add_defaults() behavior when configuration loading fails on an already configured application.
  • Improved backend resolution so backends.by_url() accepts backend classes.
  • Fixed Django task-class selection for Celery subclasses without a custom task class.
  • Limited Django fixup signal handlers to the relevant application.
  • Added a clear error when @shared_task is applied more than once.
  • Added __class_getitem__ support to generic classes.
  • Improved signal receiver identity handling for receivers bound to different instances.

Logging, Diagnostics, and Security

  • Added task_repr_maxlevels to control the depth of task argument and keyword-argument representations.
  • Added datefmt support to ColorFormatter and TaskFormatter.
  • Improved credential masking in worker inspection output, including broker read and write URLs.
  • Improved Azure credential redaction, including SAS tokens and account keys.
  • Improved URL sanitization for multi-server URLs.
  • Improved traceback handling and logging during worker timeouts and connection retries.
  • Fixed saferepr truncation to preserve balanced closing brackets.
  • Improved warning stack levels for more accurate warning locations.
  • Improved diagnostic handling of invalid worker environment values.
  • Improved certificate-expiration handling during verification.

Command-Line Interface and Utilities

  • Improved celery multi node-index handling, including index lists for named nodes.
  • Fixed celery multi failures with node names containing dashes.
  • Improved --workdir handling by expanding ~ for spawned workers.
  • Fixed escaped percent-sign handling in node formatting.
  • Improved CLI status errors with clearer messages.
  • Improved preload-option handling for commands that do not directly accept preload options.
  • Replaced deprecated codecs.open() usage in the settings upgrade command.
  • Improved regen iteration behavior, including generator slicing and source replacement.
  • Fixed BufferMap handling of bufmaxsize and its total count.
  • Improved LimitedSet timestamp and sequence-number handling when items are re-added or copied.
  • Fixed firstmethod() so it does not swallow AttributeError.
  • Improved file-descriptor iteration and cleanup behavior.
  • Cached extension entry-point discovery to reduce apply_async() CPU overhead.
  • Bounded State._tasks_to_resolve to prevent unbounded memory growth.

Compatibility and Dependencies

Python versions

Python 3.10 is now the minimum supported Python version.

Python 3.9 support has been removed from the package and its associated development and CI configurations.

This release also includes compatibility improvements for newer Python versions, including fixes for Python 3.14 annotation evaluation and function introspection behavior.

Core dependencies

  • Updated the Billiard requirement to >=4.3.1.
  • Updated the Kombu dependency to 5.7.0.
  • Updated click-repl to 0.4.0.
  • Removed explicit Redis version constraints from the requirements.
  • Replaced brotlipy with brotlicffi in the Brotli extra, with support for both CPython and PyPy.

Optional integrations and development dependencies have also received compatibility updates.

Upgrade Notes

Before upgrading, review the following points:

  • Python 3.10 or newer is required. Applications still running on Python 3.9 must upgrade their Python runtime before installing Celery 5.7.
  • Billiard and Kombu requirements have changed. Celery 5.7 requires Billiard >=4.3.1 and uses Kombu 5.7.0.
  • Review acknowledgment configuration. acks_on_failure and acks_on_timeout are now decoupled, so applications that rely on their previous combined behavior should review their task acknowledgment settings.
  • Review result expiration settings. Redis users can configure result_chord_expires and result_failure_expires independently.
  • Review custom task and backend integrations. Improvements to backend hook calling conventions and result-state handling may be relevant to custom result backends and task subclasses.
  • Review optional dependency extras. The Brotli extra now uses brotlicffi instead of brotlipy.

Consult the [Celery documentation](https://docs.celeryq.dev/en/stable/) for configuration details and upgrade guidance.

Contributors

Thank you to everyone who contributed code, tests, documentation, reviews, and feedback to this release.

This release includes contributions from many first-time contributors as well as long-standing Celery maintainers and community members. We appreciate every contribution that helped make Celery 5.7 more reliable and maintainable.

See the automatically generated contributor list and individual pull requests in the full changelog.

Full Changelog

For the complete list of changes between Celery 5.6.3 and 5.7.0, including individual pull requests and contributors, see:

[Compare v5.6.3...v5.7.0](v5.6.3...v5.7.0)

What's Changed

New Contributors

Full Changelog: v5.6.3...v5.7.0