浏览代码

Move TimeoutError to celery.exceptions

Ask Solem 15 年之前
父节点
当前提交
076d016d3a
共有 3 个文件被更改,包括 11 次插入13 次删除
  1. 3 6
      celery/backends/base.py
  2. 4 0
      celery/exceptions.py
  3. 4 7
      celery/result.py

+ 3 - 6
celery/backends/base.py

@@ -3,10 +3,7 @@ import time
 import operator
 from functools import partial as curry
 from celery.serialization import pickle
-
-
-class TimeoutError(Exception):
-    """The operation timed out."""
+from celery.exceptions import TimeoutError
 
 
 def find_nearest_pickleable_exception(exc):
@@ -178,8 +175,8 @@ class BaseBackend(object):
         will be re-raised by :func:`wait_for`.
 
         If ``timeout`` is not ``None``, this raises the
-        :class:`celery.timer.TimeoutError` exception if the operation takes
-        longer than ``timeout`` seconds.
+        :class:`celery.exceptions.TimeoutError` exception if the operation
+        takes longer than ``timeout`` seconds.
 
         """
 

+ 4 - 0
celery/exceptions.py

@@ -19,3 +19,7 @@ class NotRegistered(Exception):
 
 class AlreadyRegistered(Exception):
     """The task is already registered."""
+
+
+class TimeoutError(Exception):
+    """The operation timed out."""

+ 4 - 7
celery/result.py

@@ -5,14 +5,11 @@ Asynchronous result types.
 """
 from celery.backends import default_backend
 from celery.datastructures import PositionQueue
+from celery.exceptions import TimeoutError
 from itertools import imap
 import time
 
 
-class TimeoutError(Exception):
-    """The operation timed out."""
-
-
 class BaseAsyncResult(object):
     """Base class for pending result, supports custom
     task meta :attr:`backend`
@@ -56,8 +53,8 @@ class BaseAsyncResult(object):
         :keyword timeout: How long to wait in seconds, before the
             operation times out.
 
-        :raises TimeoutError: if ``timeout`` is not ``None`` and
-            the result does not arrive within ``timeout`` seconds.
+        :raises celery.exceptions.TimeoutError: if ``timeout`` is not ``None``
+            and the result does not arrive within ``timeout`` seconds.
 
         If the remote call raised an exception then that
         exception will be re-raised.
@@ -264,7 +261,7 @@ class TaskSetResult(object):
         :keyword timeout: The time in seconds, how long
             it will wait for results, before the operation times out.
 
-        :raises TimeoutError: if ``timeout`` is not ``None``
+        :raises celery.exceptions.TimeoutError: if ``timeout`` is not ``None``
             and the operation takes longer than ``timeout`` seconds.
 
         If any of the tasks raises an exception, the exception