소스 검색

Add doc warnings to ensure devs understand backend resource usage (#4718)

* Add warnings to ensure developers understand they must process task return values to avoid resource issues.

Specifically, the resource being consumed is redis subscriptions. Unsubscribe does not occur unless the caller explicitly cleans it up.

* Remove training whitespace to pass flake check
bartloop 7 년 전
부모
커밋
27d17c7324
3개의 변경된 파일23개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 0
      celery/result.py
  2. 8 1
      docs/getting-started/first-steps-with-celery.rst
  3. 8 0
      docs/userguide/tasks.rst

+ 7 - 0
celery/result.py

@@ -152,6 +152,13 @@ class AsyncResult(ResultBase):
            Waiting for tasks within a task may lead to deadlocks.
            Please read :ref:`task-synchronous-subtasks`.
 
+        Warning:
+           Backends use resources to store and transmit results. To ensure
+           that resources are released, you must eventually call
+           :meth:`~@AsyncResult.get` or :meth:`~@AsyncResult.forget` on
+           EVERY :class:`~@AsyncResult` instance returned after calling
+           a task.
+
         Arguments:
             timeout (float): How long to wait, in seconds, before the
                 operation times out.

+ 8 - 1
docs/getting-started/first-steps-with-celery.rst

@@ -271,7 +271,14 @@ original traceback:
 .. code-block:: pycon
 
     >>> result.traceback
-    …
+
+.. warning::
+
+    Backends use resources to store and transmit results. To ensure 
+    that resources are released, you must eventually call 
+    :meth:`~@AsyncResult.get` or :meth:`~@AsyncResult.forget` on 
+    EVERY :class:`~@AsyncResult` instance returned after calling
+    a task.
 
 See :mod:`celery.result` for the complete result object reference.
 

+ 8 - 0
docs/userguide/tasks.rst

@@ -1045,6 +1045,14 @@ No backend works well for every use case.
 You should read about the strengths and weaknesses of each backend, and choose
 the most appropriate for your needs.
 
+.. warning::
+
+    Backends use resources to store and transmit results. To ensure 
+    that resources are released, you must eventually call 
+    :meth:`~@AsyncResult.get` or :meth:`~@AsyncResult.forget` on 
+    EVERY :class:`~@AsyncResult` instance returned after calling
+    a task.
+
 .. seealso::
 
     :ref:`conf-result-backend`