Browse Source

Renamed "running" to "started"

Ask Solem 15 years ago
parent
commit
15833527be
7 changed files with 32 additions and 20 deletions
  1. 3 4
      celery/backends/base.py
  2. 2 2
      celery/conf.py
  3. 2 2
      celery/result.py
  4. 5 5
      celery/states.py
  5. 8 5
      celery/task/base.py
  6. 2 2
      celery/worker/job.py
  7. 10 0
      docs/configuration.rst

+ 3 - 4
celery/backends/base.py

@@ -36,10 +36,9 @@ class BaseBackend(object):
         raise NotImplementedError(
                 "store_result is not supported by this backend.")
 
-    def mark_as_running(self, task_id):
-        """Mark a task as currently running"""
-        print "Should mark as running now"
-        return self.store_result(task_id, None, status=states.RUNNING)
+    def mark_as_started(self, task_id):
+        """Mark a task as started"""
+        return self.store_result(task_id, None, status=states.STARTED)
 
     def mark_as_done(self, task_id, result):
         """Mark task as successfully executed."""

+ 2 - 2
celery/conf.py

@@ -62,7 +62,7 @@ _DEFAULTS = {
     "CELERY_EVENT_ROUTING_KEY": "celeryevent",
     "CELERY_RESULT_EXCHANGE": "celeryresults",
     "CELERY_MAX_CACHED_RESULTS": 5000,
-    "CELERY_TRACK_RUNNING": False,
+    "CELERY_TRACK_STARTED": False,
 }
 
 _DEPRECATION_FMT = """
@@ -92,7 +92,7 @@ CELERY_CACHE_BACKEND = _get("CELERY_CACHE_BACKEND")
 TASK_SERIALIZER = _get("CELERY_TASK_SERIALIZER")
 TASK_RESULT_EXPIRES = _get("CELERY_TASK_RESULT_EXPIRES")
 IGNORE_RESULT = _get("CELERY_IGNORE_RESULT")
-TRACK_RUNNING = _get("CELERY_TRACK_RUNNING")
+TRACK_STARTED = _get("CELERY_TRACK_STARTED")
 # Make sure TASK_RESULT_EXPIRES is a timedelta.
 if isinstance(TASK_RESULT_EXPIRES, int):
     TASK_RESULT_EXPIRES = timedelta(seconds=TASK_RESULT_EXPIRES)

+ 2 - 2
celery/result.py

@@ -128,9 +128,9 @@ class BaseAsyncResult(object):
 
                 The task is waiting for execution.
 
-            *RUNNING*
+            *STARTED*
 
-                The task is executing
+                The task has been started.
 
             *RETRY*
 

+ 5 - 5
celery/states.py

@@ -4,9 +4,9 @@
 
     Task is waiting for execution or unknown.
 
-.. data:: RUNNING
+.. data:: STARTED
 
-    Task is curretly executing on a worker
+    Task has been started.
 
 .. data:: SUCCESS
 
@@ -22,7 +22,7 @@
 
 """
 PENDING = "PENDING"
-RUNNING = "RUNNING"
+STARTED = "STARTED"
 SUCCESS = "SUCCESS"
 FAILURE = "FAILURE"
 RETRY = "RETRY"
@@ -47,9 +47,9 @@ RETRY = "RETRY"
 
 """
 READY_STATES = frozenset([SUCCESS, FAILURE])
-UNREADY_STATES = frozenset([PENDING, RUNNING, RETRY])
+UNREADY_STATES = frozenset([PENDING, STARTED, RETRY])
 EXCEPTION_STATES = frozenset([RETRY, FAILURE])
 
-ALL_STATES = frozenset([PENDING, RUNNING, SUCCESS, FAILURE, RETRY])
+ALL_STATES = frozenset([PENDING, STARTED, SUCCESS, FAILURE, RETRY])
 
 

+ 8 - 5
celery/task/base.py

@@ -153,15 +153,18 @@ class Task(object):
         If ``True`` the task is automatically registered in the task
         registry, which is the default behaviour.
 
-    .. attribute:: track_running
-        If ``True`` the task will report its status as "running" to the
-        broker when the task is executed by a worker.
+    .. attribute:: track_started
+
+        If ``True`` the task will report its status as "started"
+        when the task is executed by a worker.
         The default value is ``False`` as the normal behaviour is to not
         report that level of granularity. Tasks are either pending, finished,
-        or waiting to be retried. Having a "running" status can be useful for
+        or waiting to be retried. Having a "started" status can be useful for
         when there are long running tasks and there is a need to report which
         task is currently running.
 
+        The global default can be overridden by the ``CELERY_TRACK_STARTED``
+        setting.
 
     The resulting class is callable, which if called will apply the
     :meth:`run` method.
@@ -188,7 +191,7 @@ class Task(object):
     backend = default_backend
     exchange_type = conf.DEFAULT_EXCHANGE_TYPE
     delivery_mode = conf.DEFAULT_DELIVERY_MODE
-    track_running = conf.TRACK_RUNNING
+    track_started = conf.TRACK_STARTED
 
     MaxRetriesExceededError = MaxRetriesExceededError
 

+ 2 - 2
celery/worker/job.py

@@ -100,8 +100,8 @@ class WorkerTaskTrace(TaskTrace):
         """Execute, trace and store the result of the task."""
         self.loader.on_task_init(self.task_id, self.task)
         self.task.backend.process_cleanup()
-        if self.task.track_running:
-            self.task.backend.mark_as_running(self.task_id)
+        if self.task.track_started:
+            self.task.backend.mark_as_started(self.task_id)
         return super(WorkerTaskTrace, self).execute()
 
     def handle_success(self, retval, *args):

+ 10 - 0
docs/configuration.rst

@@ -348,6 +348,16 @@ Task execution settings
     stored task tombstones are deleted.
 
     **NOTE**: For the moment this only works with the database, cache and MongoDB
+
+* CELERY_TRACK_STARTED
+
+    If ``True`` the task will report its status as "started"
+    when the task is executed by a worker.
+    The default value is ``False`` as the normal behaviour is to not
+    report that level of granularity. Tasks are either pending, finished,
+    or waiting to be retried. Having a "started" status can be useful for
+    when there are long running tasks and there is a need to report which
+    task is currently running.
     backends.
 
 * CELERY_TASK_SERIALIZER