Browse Source

timeout/soft_timeout arguments now renamed to time_limit/soft_time_limit

Closes #1329
Ask Solem 11 years ago
parent
commit
be6cef2e44
4 changed files with 22 additions and 14 deletions
  1. 3 3
      celery/app/amqp.py
  2. 9 6
      celery/app/task.py
  3. 1 1
      celery/worker/job.py
  4. 9 4
      docs/internals/protocol.rst

+ 3 - 3
celery/app/amqp.py

@@ -191,8 +191,8 @@ class TaskProducer(Producer):
                      queue=None, now=None, retries=0, chord=None,
                      callbacks=None, errbacks=None, routing_key=None,
                      serializer=None, delivery_mode=None, compression=None,
-                     reply_to=None, timeout=None, soft_timeout=None,
-                     timeouts=None, declare=None, **kwargs):
+                     reply_to=None, time_limit=None, soft_time_limit=None,
+                     declare=None, **kwargs):
         """Send task message."""
         retry = self.retry if retry is None else retry
 
@@ -240,7 +240,7 @@ class TaskProducer(Producer):
             'callbacks': callbacks,
             'errbacks': errbacks,
             'reply_to': reply_to,
-            'timeouts': timeouts or (timeout, soft_timeout),
+            'timelimit': (time_limit, soft_time_limit),
             'taskset': group_id or taskset_id,
             'chord': chord,
         }

+ 9 - 6
celery/app/task.py

@@ -31,8 +31,8 @@ from .utils import appstr
 #: extracts attributes related to publishing a message from an object.
 extract_exec_options = mattrgetter(
     'queue', 'routing_key', 'exchange', 'priority', 'expires',
-    'serializer', 'delivery_mode', 'compression', 'timeout', 'soft_timeout',
-    'immediate', 'mandatory',  # imm+man is deprecated
+    'serializer', 'delivery_mode', 'compression', 'time_limit',
+    'soft_time_limit', 'immediate', 'mandatory',  # imm+man is deprecated
 )
 
 # We take __repr__ very seriously around here ;)
@@ -79,7 +79,7 @@ class Context(object):
     called_directly = True
     callbacks = None
     errbacks = None
-    timeouts = None
+    timelimit = None
     _children = None   # see property
     _protected = 0
 
@@ -510,13 +510,15 @@ class Task(object):
         request = self.request if request is None else request
         args = request.args if args is None else args
         kwargs = request.kwargs if kwargs is None else kwargs
+        limit_hard, limit_soft = request.timelimit or (None, None)
         options = dict({
             'task_id': request.id,
             'link': request.callbacks,
             'link_error': request.errbacks,
             'group_id': request.taskset,
             'chord': request.chord,
-            'timeouts': request.timeouts,
+            'soft_time_limit': limit_soft,
+            'time_limit': limit_hard,
         }, **request.delivery_info or {})
         return self.subtask(args, kwargs, options, type=self, **extra_options)
 
@@ -540,8 +542,9 @@ class Task(object):
         :keyword eta: Explicit time and date to run the retry at
                       (must be a :class:`~datetime.datetime` instance).
         :keyword max_retries: If set, overrides the default retry limit.
-        :keyword timeout: If set, overrides the default timeout.
-        :keyword soft_timeout: If set, overrides the default soft timeout.
+        :keyword time_limit: If set, overrides the default time limit.
+        :keyword soft_time_limit: If set, overrides the default soft
+                                  time limit.
         :keyword \*\*options: Any extra options to pass on to
                               meth:`apply_async`.
         :keyword throw: If this is :const:`False`, do not raise the

+ 1 - 1
celery/worker/job.py

@@ -217,7 +217,7 @@ class Request(object):
         request.update({'hostname': hostname, 'is_eager': False,
                         'delivery_info': self.delivery_info,
                         'group': self.request_dict.get('taskset')})
-        timeout, soft_timeout = request.get('timeouts', (None, None))
+        timeout, soft_timeout = request.get('timelimit', (None, None))
         timeout = timeout or task.time_limit
         soft_timeout = soft_timeout or task.soft_time_limit
         result = pool.apply_async(trace_task_ret,

+ 9 - 4
docs/internals/protocol.rst

@@ -99,13 +99,18 @@ to process it.
 
     A list of subtasks to apply if an error occurs while executing the task.
 
-* timeouts
-    :`tuple`:
+* timelimit
+    :`<tuple>(float, float)`:
 
     .. versionadded:: 3.1
 
-    Task execution timeouts. This is a tuple of hard and soft timeouts.
-    Timeout values are `int` or `float`.
+    Task execution time limit settings. This is a tuple of hard and soft time
+    limit value (`int`/`float` or :const:`None` for no limit).
+
+    Example value specifying a soft time limit of 3 seconds, and a hard time
+    limt of 10 seconds::
+
+        {'timelimit': (3.0, 10.0)}
 
 
 Example message