Kaynağa Gözat

Updates Changelog

Ask Solem 14 yıl önce
ebeveyn
işleme
0d169a7071
2 değiştirilmiş dosya ile 42 ekleme ve 1 silme
  1. 32 1
      Changelog
  2. 10 0
      docs/userguide/tasks.rst

+ 32 - 1
Changelog

@@ -80,9 +80,40 @@ News
         ...         for i in xrange(100))(tsum.subtask()).get()
         9900
 
-    Please read the :ref:`Chord section in the user guide <chord>`, if you
+    Please read the :ref:`Chords section in the user guide <chords>`, if you
     want to know more.
 
+* Time limits can now be set for individual tasks.
+
+	To set the soft and hard time limits for a task use the ``time_limit``
+	and ``soft_time_limit`` attributes:
+
+	.. code-block:: python
+
+		import time
+
+		@task(time_limit=60, soft_time_limit=30)
+		def sleeptask(seconds):
+			time.sleep(seconds)
+
+	If the attributes are not set, then the workers default time limits
+	will be used.
+
+	New in this version you can also change the time limits for a task
+	at runtime using the :func:`time_limit` remote control command::
+
+		>>> from celery.task import control
+		>>> control.time_limit("tasks.sleeptask",
+		...					   soft=60, hard=120, reply=True)
+		[{'worker1.example.com': {'ok': 'time limits set successfully'}}]
+
+	Only tasks that starts executing after the time limit change will be affected.
+
+	.. note::
+
+		Soft time limits will still not work on Windows or other platforms
+		that do not have the ``SIGUSR1`` signal.
+
 .. _version-2.2.5:
 
 2.2.5

+ 10 - 0
docs/userguide/tasks.rst

@@ -213,6 +213,16 @@ General
     :setting:`CELERY_DEFAULT_RATE_LIMIT` setting, which if not specified means
     rate limiting for tasks is disabled by default.
 
+.. attribute:: Task.time_limit
+
+    The hard time limit for this task.  If not set then the workers default
+    will be used.
+
+.. attribute:: Task.soft_time_limit
+
+    The soft time limit for this task.  If not set then the workers default
+    will be used.
+
 .. attribute:: Task.ignore_result
 
     Don't store task state.    Note that this means you can't use