فهرست منبع

Use @app.task consistently

Ask Solem 11 سال پیش
والد
کامیت
5fb799203f
7فایلهای تغییر یافته به همراه17 افزوده شده و 17 حذف شده
  1. 1 1
      celery/contrib/methods.py
  2. 1 1
      docs/configuration.rst
  3. 5 5
      docs/faq.rst
  4. 2 2
      docs/internals/app-overview.rst
  5. 1 1
      docs/internals/guide.rst
  6. 2 2
      docs/reference/celery.rst
  7. 5 5
      docs/userguide/canvas.rst

+ 1 - 1
celery/contrib/methods.py

@@ -26,7 +26,7 @@ or with any task decorator:
 
     class X(object):
 
-        @celery.task(filter=task_method)
+        @app.task(filter=task_method)
         def add(self, x, y):
             return x + y
 

+ 1 - 1
docs/configuration.rst

@@ -1315,7 +1315,7 @@ Example:
 
     from celery.exceptions import SoftTimeLimitExceeded
 
-    @celery.task
+    @app.task
     def mytask():
         try:
             return do_work()

+ 5 - 5
docs/faq.rst

@@ -526,7 +526,7 @@ If you don't use the results for a task, make sure you set the
 
 .. code-block python
 
-    @celery.task(ignore_result=True)
+    @app.task(ignore_result=True)
     def mytask():
 
@@ -620,7 +620,7 @@ How can I get the task id of the current task?
 
 **Answer**: The current id and more is available in the task request::
 
-    @celery.task(bind=True)
+    @app.task(bind=True)
     def mytask(self):
         cache.set(self.request.id, "Running")
 
@@ -666,11 +666,11 @@ Also, a common pattern is to add callbacks to tasks:
 
     logger = get_task_logger(__name__)
 
-    @celery.task
+    @app.task
     def add(x, y):
         return x + y
 
-    @celery.task(ignore_result=True)
+    @app.task(ignore_result=True)
     def log_result(result):
         logger.info("log_result got: %r", result)
 
@@ -779,7 +779,7 @@ this is rarely the case. Imagine the following task:
 
 .. code-block:: python
 
-    @celery.task
+    @app.task
     def process_upload(filename, tmpfile):
         # Increment a file count stored in a database
         increment_file_counter()

+ 2 - 2
docs/internals/app-overview.rst

@@ -25,7 +25,7 @@ Creating tasks:
 
 .. code-block:: python
 
-    @celery.task
+    @app.task
     def add(x, y):
         return x + y
 
@@ -43,7 +43,7 @@ Creating custom Task subclasses:
             import pdb
             pdb.set_trace()
 
-    @celery.task(base=DebugTask)
+    @app.task(base=DebugTask)
     def add(x, y):
         return x + y
 

+ 1 - 1
docs/internals/guide.rst

@@ -205,7 +205,7 @@ and here's the same using Celery app objects:
     from .celery import celery
     from .models import CeleryStats
 
-    @celery.task
+    @app.task
     def write_stats_to_db():
         stats = celery.control.inspect().stats(timeout=1)
         for node_name, reply in stats:

+ 2 - 2
docs/reference/celery.rst

@@ -243,7 +243,7 @@ and creating Celery applications.
 
         .. code-block:: python
 
-            @celery.task
+            @app.task
             def refresh_feed(url):
                 return …
 
@@ -251,7 +251,7 @@ and creating Celery applications.
 
         .. code-block:: python
 
-            @celery.task(exchange="feeds")
+            @app.task(exchange="feeds")
             def refresh_feed(url):
                 return …
 

+ 5 - 5
docs/userguide/canvas.rst

@@ -669,11 +669,11 @@ already a standard function):
 
 .. code-block:: python
 
-    @celery.task
+    @app.task
     def add(x, y):
         return x + y
 
-    @celery.task
+    @app.task
     def tsum(numbers):
         return sum(numbers)
 
@@ -785,7 +785,7 @@ Example decorated task:
 
 .. code-block:: python
 
-    @celery.task(ignore_result=False)
+    @app.task(ignore_result=False)
     def another_task(project):
         do_something()
 
@@ -855,7 +855,7 @@ is the same as having a task doing:
 
 .. code-block:: python
 
-    @celery.task
+    @app.task
     def temp():
         return [xsum(range(10)), xsum(range(100))]
 
@@ -868,7 +868,7 @@ is the same as having a task doing:
 
 .. code-block:: python
 
-    @celery.task
+    @app.task
     def temp():
         return [add(i, i) for i in range(10)]