Sfoglia il codice sorgente

Added FAQ: Can I cancel the execution of a task?

Ask Solem 15 anni fa
parent
commit
d1f0af090c
1 ha cambiato i file con 13 aggiunte e 1 eliminazioni
  1. 13 1
      FAQ

+ 13 - 1
FAQ

@@ -423,7 +423,7 @@ Features
 How can I run a task once another task has finished?
 ----------------------------------------------------
 
-You can safely launch a task inside a task.
+**Answer**: You can safely launch a task inside a task.
 Also, a common pattern is to use callback tasks:
 
 .. code-block:: python
@@ -444,6 +444,18 @@ Also, a common pattern is to use callback tasks:
 
     >>> add.delay(2, 2, callback=log_result)
 
+Can I cancel the execution of a task?
+-------------------------------------
+**Answer**: Yes. Use ``result.revoke``::
+
+    >>> result = add.apply_async(args=[2, 2], countdown=120)
+    >>> result.revoke()
+
+or if you only have the task id::
+
+    >>> from celery.task.control import revoke
+    >>> revoke(task_id)
+
 Can I send some tasks to only some servers?
 --------------------------------------------