Debian Codegraph @

docs/history/whatsnew-5.5.rst

raw
1 .. _whatsnew-5.5:
2
3 =========================================
4 What's new in Celery 5.5 (Immunity)
5 =========================================
6 :Author: Tomer Nosrati (``tomer.nosrati 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, 3.11, 3.12 and 3.13.
41 and is also supported on PyPy3.10+.
42
43 .. _`website`: https://celery.readthedocs.io
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: 3
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.5.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 `Immunity <https://www.youtube.com/watch?v=Y8eQR5DMous>`_.
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 *— Tomer Nosrati*
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 Upgrading from Celery 4.x
85 =========================
86
87 Step 1: Adjust your command line invocation
88 -------------------------------------------
89
90 Celery 5.0 introduces a new CLI implementation which isn't completely backwards compatible.
91
92 The global options can no longer be positioned after the sub-command.
93 Instead, they must be positioned as an option for the `celery` command like so::
94
95 celery --app path.to.app worker
96
97 If you were using our :ref:`daemonizing` guide to deploy Celery in production,
98 you should revisit it for updates.
99
100 Step 2: Update your configuration with the new setting names
101 ------------------------------------------------------------
102
103 If you haven't already updated your configuration when you migrated to Celery 4.0,
104 please do so now.
105
106 We elected to extend the deprecation period until 6.0 since
107 we did not loudly warn about using these deprecated settings.
108
109 Please refer to the :ref:`migration guide <conf-old-settings-map>` for instructions.
110
111 Step 3: Read the important notes in this document
112 -------------------------------------------------
113
114 Make sure you are not affected by any of the important upgrade notes
115 mentioned in the :ref:`following section <v550-important>`.
116
117 You should verify that none of the breaking changes in the CLI
118 do not affect you. Please refer to :ref:`New Command Line Interface <new_command_line_interface>` for details.
119
120 Step 4: Migrate your code to Python 3
121 -------------------------------------
122
123 Celery 5.x only supports Python 3. Therefore, you must ensure your code is
124 compatible with Python 3.
125
126 If you haven't ported your code to Python 3, you must do so before upgrading.
127
128 You can use tools like `2to3 <https://docs.python.org/3.8/library/2to3.html>`_
129 and `pyupgrade <https://github.com/asottile/pyupgrade>`_ to assist you with
130 this effort.
131
132 After the migration is done, run your test suite with Celery 5 to ensure
133 nothing has been broken.
134
135 Step 5: Upgrade to Celery 5.5
136 -----------------------------
137
138 At this point you can upgrade your workers and clients with the new version.
139
140 .. _v550-important:
141
142 Important Notes
143 ===============
144
145 Supported Python Versions
146 -------------------------
147
148 The supported Python versions are:
149
150 - CPython 3.8
151 - CPython 3.9
152 - CPython 3.10
153 - CPython 3.11
154 - CPython 3.12
155 - CPython 3.13
156 - PyPy3.10 (``pypy3``)
157
158 Python 3.8 Support
159 ------------------
160
161 Python 3.8 will reach EOL in October, 2024.
162
163 Minimum Dependencies
164 --------------------
165
166 Kombu
167 ~~~~~
168
169 Starting from Celery v5.5, the minimum required version is Kombu 5.5.
170
171 Redis
172 ~~~~~
173
174 redis-py 4.5.2 is the new minimum required version.
175
176
177 SQLAlchemy
178 ~~~~~~~~~~
179
180 SQLAlchemy 1.4.x & 2.0.x is now supported in Celery v5.5.
181
182 Billiard
183 ~~~~~~~~
184
185 Minimum required version is now 4.2.1.
186
187 Django
188 ~~~~~~
189
190 Minimum django version is bumped to v2.2.28.
191 Also added --skip-checks flag to bypass django core checks.
192
193 .. _v550-news:
194
195 News
196 ====
197
198 Redis Broker Stability Improvements
199 -----------------------------------
200
201 Long-standing disconnection issues with the Redis broker have been identified and
202 resolved in Kombu 5.5.0. These improvements significantly enhance stability when
203 using Redis as a broker, particularly in high-throughput environments.
204
205 Additionally, the Redis backend now has better exception handling with the new
206 ``exception_safe_to_retry`` feature, which improves resilience during temporary
207 Redis connection issues. See :ref:`conf-redis-result-backend` for complete
208 documentation.
209
210 ``pycurl`` replaced with ``urllib3``
211 ------------------------------------
212
213 Replaced the :pypi:`pycurl` dependency with :pypi:`urllib3`.
214
215 We're monitoring the performance impact of this change and welcome feedback from users
216 who notice any significant differences in their environments.
217
218 RabbitMQ Quorum Queues Support
219 ------------------------------
220
221 Added support for RabbitMQ's new `Quorum Queues <https://www.rabbitmq.com/docs/quorum-queues>`_
222 feature, including compatibility with ETA tasks. This implementation has some limitations compared
223 to classic queues, so please refer to the documentation for details.
224
225 `Native Delayed Delivery <https://docs.particular.net/transports/rabbitmq/delayed-delivery>`_
226 is automatically enabled when quorum queues are detected to implement the ETA mechanism.
227
228 See :ref:`using-quorum-queues` for complete documentation.
229
230 Configuration options:
231
232 - :setting:`broker_native_delayed_delivery_queue_type`: Specifies the queue type for
233 delayed delivery (default: ``quorum``)
234 - :setting:`task_default_queue_type`: Sets the default queue type for tasks
235 (default: ``classic``)
236 - :setting:`worker_detect_quorum_queues`: Controls automatic detection of quorum
237 queues (default: ``True``)
238
239 Soft Shutdown Mechanism
240 -----------------------
241
242 Soft shutdown is a time limited warm shutdown, initiated just before the cold shutdown.
243 The worker will allow :setting:`worker_soft_shutdown_timeout` seconds for all currently
244 executing tasks to finish before it terminates. If the time limit is reached, the worker
245 will initiate a cold shutdown and cancel all currently executing tasks.
246
247 This feature is particularly valuable when using brokers with visibility timeout
248 mechanisms, such as Redis or SQS. It allows the worker enough time to re-queue
249 tasks that were not completed before exiting, preventing task loss during worker
250 shutdown.
251
252 See :ref:`worker-stopping` for complete documentation on worker shutdown types.
253
254 Configuration options:
255
256 - :setting:`worker_soft_shutdown_timeout`: Sets the duration in seconds for the soft
257 shutdown period (default: ``0.0``, disabled)
258 - :setting:`worker_enable_soft_shutdown_on_idle`: Controls whether soft shutdown
259 should be enabled even when the worker is idle (default: ``False``)
260
261 Pydantic Support
262 ----------------
263
264 New native support for Pydantic models in tasks. This integration allows you to
265 leverage Pydantic's powerful data validation and serialization capabilities directly
266 in your Celery tasks.
267
268 Example usage:
269
270 .. code-block:: python
271
272 from pydantic import BaseModel
273 from celery import Celery
274
275 app = Celery('tasks')
276
277 class ArgModel(BaseModel):
278 value: int
279
280 class ReturnModel(BaseModel):
281 value: str
282
283 @app.task(pydantic=True)
284 def x(arg: ArgModel) -> ReturnModel:
285 # args/kwargs type hinted as Pydantic model will be converted
286 assert isinstance(arg, ArgModel)
287
288 # The returned model will be converted to a dict automatically
289 return ReturnModel(value=f"example: {arg.value}")
290
291 See :ref:`task-pydantic` for complete documentation.
292
293 Configuration options:
294
295 - ``pydantic=True``: Enables Pydantic integration for the task
296 - ``pydantic_strict=True/False``: Controls whether strict validation is enabled
297 (default: ``False``)
298 - ``pydantic_context={...}``: Provides additional context for validation
299 - ``pydantic_dump_kwargs={...}``: Customizes serialization behavior
300
301 Google Pub/Sub Transport
302 ------------------------
303
304 New support for Google Cloud Pub/Sub as a message transport, expanding Celery's
305 cloud integration options.
306
307 See :ref:`broker-gcpubsub` for complete documentation.
308
309 For the Google Pub/Sub support you have to install additional dependencies:
310
311 .. code-block:: console
312
313 $ pip install "celery[gcpubsub]"
314
315 Then configure your Celery application to use the Google Pub/Sub transport:
316
317 .. code-block:: python
318
319 broker_url = 'gcpubsub://projects/project-id'
320
321 Python 3.13 Support
322 -------------------
323
324 Official support for Python 3.13. All core dependencies have been updated to
325 ensure compatibility, including Kombu and py-amqp.
326
327 This release maintains compatibility with Python 3.8 through 3.13, as well as
328 PyPy 3.10+.
329
330 REMAP_SIGTERM Support
331 ---------------------
332
333 The "REMAP_SIGTERM" feature, previously undocumented, has been tested, documented,
334 and is now officially supported. This feature allows you to remap the SIGTERM
335 signal to SIGQUIT, enabling you to initiate a soft or cold shutdown using TERM
336 instead of QUIT.
337
338 This is particularly useful in containerized environments where SIGTERM is the
339 standard signal for graceful termination.
340
341 See :ref:`Cold Shutdown documentation <worker-REMAP_SIGTERM>` for more info.
342
343 To enable this feature, set the environment variable:
344
345 .. code-block:: bash
346
347 export REMAP_SIGTERM="SIGQUIT"
348
349 Database Backend Improvements
350 ----------------------------
351
352 New ``create_tables_at_setup`` option for the database backend. This option
353 controls when database tables are created, allowing for non-lazy table creation.
354
355 By default (``create_tables_at_setup=True``), tables are created during backend
356 initialization. Setting this to ``False`` defers table creation until they are
357 actually needed, which can be useful in certain deployment scenarios where you want
358 more control over database schema management.
359
360 See :ref:`conf-database-result-backend` for complete documentation.