| 1 |
.. _whatsnew-5.3: |
| 2 |
|
| 3 |
========================================= |
| 4 |
What's new in Celery 5.3 (Emerald Rush) |
| 5 |
========================================= |
| 6 |
:Author: Asif Saif Uddin (``auvipy at gmail.com``). |
| 7 |
|
| 8 |
.. sidebar:: Change history |
| 9 |
|
| 10 |
What's new documents describe the changes in major versions, |
| 11 |
we also have a :ref:`changelog` that lists the changes in bugfix |
| 12 |
releases (0.0.x), while older series are archived under the :ref:`history` |
| 13 |
section. |
| 14 |
|
| 15 |
Celery is a simple, flexible, and reliable distributed programming framework |
| 16 |
to process vast amounts of messages, while providing operations with |
| 17 |
the tools required to maintain a distributed system with python. |
| 18 |
|
| 19 |
It's a task queue with focus on real-time processing, while also |
| 20 |
supporting task scheduling. |
| 21 |
|
| 22 |
Celery has a large and diverse community of users and contributors, |
| 23 |
you should come join us :ref:`on IRC <irc-channel>` |
| 24 |
or :ref:`our mailing-list <mailing-list>`. |
| 25 |
|
| 26 |
.. note:: |
| 27 |
|
| 28 |
Following the problems with Freenode, we migrated our IRC channel to Libera Chat |
| 29 |
as most projects did. |
| 30 |
You can also join us using `Gitter <https://gitter.im/celery/celery>`_. |
| 31 |
|
| 32 |
We're sometimes there to answer questions. We welcome you to join. |
| 33 |
|
| 34 |
To read more about Celery you should go read the :ref:`introduction <intro>`. |
| 35 |
|
| 36 |
While this version is **mostly** backward compatible with previous versions |
| 37 |
it's important that you read the following section as this release |
| 38 |
is a new major version. |
| 39 |
|
| 40 |
This version is officially supported on CPython 3.8, 3.9 & 3.10 |
| 41 |
and is also supported on PyPy3.8+. |
| 42 |
|
| 43 |
.. _`website`: https://docs.celeryq.dev/en/stable/ |
| 44 |
|
| 45 |
.. topic:: Table of Contents |
| 46 |
|
| 47 |
Make sure you read the important notes before upgrading to this version. |
| 48 |
|
| 49 |
.. contents:: |
| 50 |
:local: |
| 51 |
:depth: 2 |
| 52 |
|
| 53 |
Preface |
| 54 |
======= |
| 55 |
|
| 56 |
.. note:: |
| 57 |
|
| 58 |
**This release contains fixes for many long standing bugs & stability issues. |
| 59 |
We encourage our users to upgrade to this release as soon as possible.** |
| 60 |
|
| 61 |
The 5.3.0 release is a new feature release for Celery. |
| 62 |
|
| 63 |
Releases in the 5.x series are codenamed after songs of `Jon Hopkins <https://en.wikipedia.org/wiki/Jon_Hopkins>`_. |
| 64 |
This release has been codenamed `Emerald Rush <https://www.youtube.com/watch?v=4sk0uDbM5lc>`_. |
| 65 |
|
| 66 |
From now on we only support Python 3.8 and above. |
| 67 |
We will maintain compatibility with Python 3.8 until it's |
| 68 |
EOL in 2024. |
| 69 |
|
| 70 |
*— Asif Saif Uddin* |
| 71 |
|
| 72 |
Long Term Support Policy |
| 73 |
------------------------ |
| 74 |
|
| 75 |
We no longer support Celery 4.x as we don't have the resources to do so. |
| 76 |
If you'd like to help us, all contributions are welcome. |
| 77 |
|
| 78 |
Celery 5.x **is not** an LTS release. We will support it until the release |
| 79 |
of Celery 6.x. |
| 80 |
|
| 81 |
We're in the process of defining our Long Term Support policy. |
| 82 |
Watch the next "What's New" document for updates. |
| 83 |
|
| 84 |
Wall of Contributors |
| 85 |
-------------------- |
| 86 |
|
| 87 |
.. note:: |
| 88 |
|
| 89 |
This wall was automatically generated from git history, |
| 90 |
so sadly it doesn't not include the people who help with more important |
| 91 |
things like answering mailing-list questions. |
| 92 |
|
| 93 |
Upgrading from Celery 4.x |
| 94 |
========================= |
| 95 |
|
| 96 |
Step 1: Adjust your command line invocation |
| 97 |
------------------------------------------- |
| 98 |
|
| 99 |
Celery 5.0 introduces a new CLI implementation which isn't completely backwards compatible. |
| 100 |
|
| 101 |
The global options can no longer be positioned after the sub-command. |
| 102 |
Instead, they must be positioned as an option for the `celery` command like so:: |
| 103 |
|
| 104 |
celery --app path.to.app worker |
| 105 |
|
| 106 |
If you were using our :ref:`daemonizing` guide to deploy Celery in production, |
| 107 |
you should revisit it for updates. |
| 108 |
|
| 109 |
Step 2: Update your configuration with the new setting names |
| 110 |
------------------------------------------------------------ |
| 111 |
|
| 112 |
If you haven't already updated your configuration when you migrated to Celery 4.0, |
| 113 |
please do so now. |
| 114 |
|
| 115 |
We elected to extend the deprecation period until 6.0 since |
| 116 |
we did not loudly warn about using these deprecated settings. |
| 117 |
|
| 118 |
Please refer to the :ref:`migration guide <conf-old-settings-map>` for instructions. |
| 119 |
|
| 120 |
Step 3: Read the important notes in this document |
| 121 |
------------------------------------------------- |
| 122 |
|
| 123 |
Make sure you are not affected by any of the important upgrade notes |
| 124 |
mentioned in the :ref:`following section <v500-important>`. |
| 125 |
|
| 126 |
You should verify that none of the breaking changes in the CLI |
| 127 |
do not affect you. Please refer to :ref:`New Command Line Interface <new_command_line_interface>` for details. |
| 128 |
|
| 129 |
Step 4: Migrate your code to Python 3 |
| 130 |
------------------------------------- |
| 131 |
|
| 132 |
Celery 5.x only supports Python 3. Therefore, you must ensure your code is |
| 133 |
compatible with Python 3. |
| 134 |
|
| 135 |
If you haven't ported your code to Python 3, you must do so before upgrading. |
| 136 |
|
| 137 |
You can use tools like `2to3 <https://docs.python.org/3.8/library/2to3.html>`_ |
| 138 |
and `pyupgrade <https://github.com/asottile/pyupgrade>`_ to assist you with |
| 139 |
this effort. |
| 140 |
|
| 141 |
After the migration is done, run your test suite with Celery 4 to ensure |
| 142 |
nothing has been broken. |
| 143 |
|
| 144 |
Step 5: Upgrade to Celery 5.3 |
| 145 |
----------------------------- |
| 146 |
|
| 147 |
At this point you can upgrade your workers and clients with the new version. |
| 148 |
|
| 149 |
.. _v530-important: |
| 150 |
|
| 151 |
Important Notes |
| 152 |
=============== |
| 153 |
|
| 154 |
Supported Python Versions |
| 155 |
------------------------- |
| 156 |
|
| 157 |
The supported Python versions are: |
| 158 |
|
| 159 |
- CPython 3.8 |
| 160 |
- CPython 3.9 |
| 161 |
- CPython 3.10 |
| 162 |
- PyPy3.8 7.3.11 (``pypy3``) |
| 163 |
|
| 164 |
Experimental support |
| 165 |
~~~~~~~~~~~~~~~~~~~~ |
| 166 |
|
| 167 |
Celery supports these Python versions provisionally as they are not production |
| 168 |
ready yet: |
| 169 |
|
| 170 |
- CPython 3.11 |
| 171 |
|
| 172 |
Quality Improvements and Stability Enhancements |
| 173 |
----------------------------------------------- |
| 174 |
|
| 175 |
Celery 5.3 focuses on elevating the overall quality and stability of the project. |
| 176 |
We have dedicated significant efforts to address various bugs, enhance performance, |
| 177 |
and make improvements based on valuable user feedback. |
| 178 |
|
| 179 |
Better Compatibility and Upgrade Confidence |
| 180 |
------------------------------------------- |
| 181 |
|
| 182 |
Our goal with Celery 5.3 is to instill confidence in users who are currently |
| 183 |
using Celery 4 or older versions. We want to assure you that upgrading to |
| 184 |
Celery 5.3 will provide a more robust and reliable experience. |
| 185 |
|
| 186 |
|
| 187 |
Dropped support for Python 3.7 |
| 188 |
------------------------------ |
| 189 |
|
| 190 |
Celery now requires Python 3.8 and above. |
| 191 |
|
| 192 |
Python 3.7 will reach EOL in June, 2023. |
| 193 |
In order to focus our efforts we have dropped support for Python 3.6 in |
| 194 |
this version. |
| 195 |
|
| 196 |
If you still require to run Celery using Python 3.7 |
| 197 |
you can still use Celery 5.2. |
| 198 |
However we encourage you to upgrade to a supported Python version since |
| 199 |
no further security patches will be applied for Python 3.7 after |
| 200 |
the 23th of June, 2023. |
| 201 |
|
| 202 |
|
| 203 |
Automatic re-connection on connection loss to broker |
| 204 |
---------------------------------------------------- |
| 205 |
|
| 206 |
Unless :setting:`broker_connection_retry_on_startup` is set to False, |
| 207 |
Celery will automatically retry reconnecting to the broker after |
| 208 |
the first connection loss. :setting:`broker_connection_retry` controls |
| 209 |
whether to automatically retry reconnecting to the broker for subsequent |
| 210 |
reconnects. |
| 211 |
|
| 212 |
Since the message broker does not track how many tasks were already fetched |
| 213 |
before the connection was lost, Celery will reduce the prefetch count by |
| 214 |
the number of tasks that are currently running multiplied by |
| 215 |
:setting:`worker_prefetch_multiplier`. |
| 216 |
The prefetch count will be gradually restored to the maximum allowed after |
| 217 |
each time a task that was running before the connection was lost is complete |
| 218 |
|
| 219 |
|
| 220 |
Kombu |
| 221 |
----- |
| 222 |
|
| 223 |
Starting from v5.3.0, the minimum required version is Kombu 5.3.0. |
| 224 |
|
| 225 |
Redis |
| 226 |
----- |
| 227 |
|
| 228 |
redis-py 4.5.x is the new minimum required version. |
| 229 |
|
| 230 |
|
| 231 |
SQLAlchemy |
| 232 |
--------------------- |
| 233 |
|
| 234 |
SQLAlchemy 1.4.x & 2.0.x is now supported in celery v5.3 |
| 235 |
|
| 236 |
|
| 237 |
Billiard |
| 238 |
------------------- |
| 239 |
|
| 240 |
Minimum required version is now 4.1.0 |
| 241 |
|
| 242 |
|
| 243 |
Deprecate pytz and use zoneinfo |
| 244 |
------------------------------- |
| 245 |
|
| 246 |
A switch have been made to zoneinfo for handling timezone data instead of pytz. |
| 247 |
|
| 248 |
|
| 249 |
Support for out-of-tree worker pool implementations |
| 250 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 251 |
Prior to version 5.3, Celery had a fixed notion of the worker pool types it supports. |
| 252 |
Celery v5.3.0 introduces the possibility of an out-of-tree worker pool implementation. |
| 253 |
This feature ensures that the current worker pool implementations consistently call into |
| 254 |
BasePool._get_info(), and enhances it to report the worker pool class in use via the |
| 255 |
"celery inspect stats" command. For example: |
| 256 |
|
| 257 |
$ celery -A ... inspect stats |
| 258 |
-> celery@freenas: OK |
| 259 |
{ |
| 260 |
... |
| 261 |
"pool": { |
| 262 |
... |
| 263 |
"implementation": "celery_aio_pool.pool:AsyncIOPool", |
| 264 |
|
| 265 |
It can be used as follows: |
| 266 |
|
| 267 |
Set the environment variable CELERY_CUSTOM_WORKER_POOL to the name of |
| 268 |
an implementation of :class:celery.concurrency.base.BasePool in the |
| 269 |
standard Celery format of "package:class". |
| 270 |
|
| 271 |
Select this pool using '--pool custom'. |
| 272 |
|
| 273 |
|
| 274 |
Signal::``worker_before_create_process`` |
| 275 |
---------------------------------------- |
| 276 |
|
| 277 |
Dispatched in the parent process, just before new child process is created in the prefork pool. |
| 278 |
It can be used to clean up instances that don't behave well when forking. |
| 279 |
|
| 280 |
.. code-block:: python |
| 281 |
|
| 282 |
@signals.worker_before_create_process.connect |
| 283 |
def clean_channels(**kwargs): |
| 284 |
grpc_singleton.clean_channel() |
| 285 |
|
| 286 |
|
| 287 |
Setting::``beat_cron_starting_deadline`` |
| 288 |
---------------------------------------- |
| 289 |
|
| 290 |
When using cron, the number of seconds :mod:`~celery.bin.beat` can look back |
| 291 |
when deciding whether a cron schedule is due. When set to `None`, cronjobs that |
| 292 |
are past due will always run immediately. |
| 293 |
|
| 294 |
|
| 295 |
Redis result backend Global keyprefix |
| 296 |
------------------------------------- |
| 297 |
|
| 298 |
The global key prefix will be prepended to all keys used for the result backend, |
| 299 |
which can be useful when a redis database is shared by different users. |
| 300 |
By default, no prefix is prepended. |
| 301 |
|
| 302 |
To configure the global keyprefix for the Redis result backend, use the |
| 303 |
``global_keyprefix`` key under :setting:`result_backend_transport_options`: |
| 304 |
|
| 305 |
|
| 306 |
.. code-block:: python |
| 307 |
|
| 308 |
app.conf.result_backend_transport_options = { |
| 309 |
'global_keyprefix': 'my_prefix_' |
| 310 |
} |
| 311 |
|
| 312 |
|
| 313 |
Django |
| 314 |
------ |
| 315 |
|
| 316 |
Minimum django version is bumped to v2.2.28. |
| 317 |
Also added --skip-checks flag to bypass django core checks. |
| 318 |
|
| 319 |
|
| 320 |
Make default worker state limits configurable |
| 321 |
--------------------------------------------- |
| 322 |
|
| 323 |
Previously, `REVOKES_MAX`, `REVOKE_EXPIRES`, `SUCCESSFUL_MAX` and |
| 324 |
`SUCCESSFUL_EXPIRES` were hardcoded in `celery.worker.state`. This |
| 325 |
version introduces `CELERY_WORKER_` prefixed environment variables |
| 326 |
with the same names that allow you to customize these values should |
| 327 |
you need to. |
| 328 |
|
| 329 |
|
| 330 |
Canvas stamping |
| 331 |
--------------- |
| 332 |
|
| 333 |
The goal of the Stamping API is to give an ability to label the signature |
| 334 |
and its components for debugging information purposes. For example, when |
| 335 |
the canvas is a complex structure, it may be necessary to label some or |
| 336 |
all elements of the formed structure. The complexity increases even more |
| 337 |
when nested groups are rolled-out or chain elements are replaced. In such |
| 338 |
cases, it may be necessary to understand which group an element is a part |
| 339 |
of or on what nested level it is. This requires a mechanism that traverses |
| 340 |
the canvas elements and marks them with specific metadata. The stamping API |
| 341 |
allows doing that based on the Visitor pattern. |
| 342 |
|
| 343 |
|
| 344 |
Known Issues |
| 345 |
------------ |
| 346 |
Canvas header stamping has issues in a hybrid Celery 4.x. & Celery 5.3.x |
| 347 |
environment and is not safe for production use at the moment. |
| 348 |
|
| 349 |
|
| 350 |
|