فهرست منبع

Added Task.update_state(task_id, state, meta)

as a shortcut to task.backend.store_result(task_id, meta, state).
The backend interface is "private" and the terminology outdated,
so better to move this to Task so it can be used.
Ask Solem 14 سال پیش
والد
کامیت
5fcf40f63b
1فایلهای تغییر یافته به همراه12 افزوده شده و 0 حذف شده
  1. 12 0
      celery/task/base.py

+ 12 - 0
celery/task/base.py

@@ -583,6 +583,18 @@ class BaseTask(object):
         """
         return self.app.AsyncResult(task_id, backend=self.backend)
 
+    def update_state(self, task_id, state, meta=None):
+        """Update task state.
+
+        :param task_id: Id of the task to update.
+        :param state: New state (:class:`str`).
+        :param meta: State metadata (:class:`dict`).
+
+        """
+        if meta is None:
+            meta = {}
+        self.backend.store_result(task_id, meta, state)
+
     def on_retry(self, exc, task_id, args, kwargs, einfo=None):
         """Retry handler.