Browse Source

Add :setting: ref to all settings in docstrings

Ask Solem 14 years ago
parent
commit
8a3b4765fb

+ 1 - 1
celery/backends/cassandra.py

@@ -44,7 +44,7 @@ class CassandraBackend(BaseDictBackend):
         """Initialize Cassandra backend.
 
         Raises :class:`celery.exceptions.ImproperlyConfigured` if
-        the ``CASSANDRA_SERVERS`` setting is not set.
+        the :setting:`CASSANDRA_SERVERS` setting is not set.
 
         """
         super(CassandraBackend, self).__init__(**kwargs)

+ 1 - 1
celery/backends/pyredis.py

@@ -25,7 +25,7 @@ class RedisBackend(KeyValueStoreBackend):
         The port to the Redis server.
 
         Raises :class:`celery.exceptions.ImproperlyConfigured` if
-        the ``REDIS_HOST`` or ``REDIS_PORT`` settings is not set.
+        the :setting:`REDIS_HOST` or :setting:`REDIS_PORT` settings is not set.
 
     """
     redis_host = "localhost"

+ 2 - 2
celery/loaders/default.py

@@ -72,8 +72,8 @@ class Loader(BaseLoader):
         """Imports modules at worker init so tasks can be registered
         and used by the worked.
 
-        The list of modules to import is taken from the ``CELERY_IMPORTS``
-        setting in ``celeryconf.py``.
+        The list of modules to import is taken from the
+        :setting:`CELERY_IMPORTS` setting.
 
         """
         self.import_default_modules()

+ 1 - 1
celery/messaging.py

@@ -31,7 +31,7 @@ def get_consumer_set(connection, queues=None, **options):
     """Get the :class:`carrot.messaging.ConsumerSet`` for a queue
     configuration.
 
-    Defaults to the queues in ``CELERY_QUEUES``.
+    Defaults to the queues in :const:`CELERY_QUEUES`.
 
     """
     # FIXME: Deprecate!

+ 16 - 14
celery/result.py

@@ -54,8 +54,9 @@ class BaseAsyncResult(object):
         :keyword timeout: How long to wait, in seconds, before the
             operation times out.
 
-        :raises celery.exceptions.TimeoutError: if ``timeout`` is not ``None``
-            and the result does not arrive within ``timeout`` seconds.
+        :raises celery.exceptions.TimeoutError: if ``timeout`` is not
+            :const:`None` and the result does not arrive within ``timeout``
+            seconds.
 
         If the remote call raised an exception then that
         exception will be re-raised.
@@ -68,21 +69,21 @@ class BaseAsyncResult(object):
         return self.wait(timeout=timeout)
 
     def ready(self):
-        """Returns ``True`` if the task executed successfully, or raised
+        """Returns :const:`True` if the task executed successfully, or raised
         an exception.
 
         If the task is still running, pending, or is waiting
-        for retry then ``False`` is returned.
+        for retry then :const:`False` is returned.
 
         """
         return self.status not in self.backend.UNREADY_STATES
 
     def successful(self):
-        """Returns ``True`` if the task executed successfully."""
+        """Returns :const:`True` if the task executed successfully."""
         return self.status == states.SUCCESS
 
     def failed(self):
-        """Returns ``True`` if the task failed by exception."""
+        """Returns :const:`True` if the task failed by exception."""
         return self.status == states.FAILURE
 
     def __str__(self):
@@ -210,7 +211,7 @@ class TaskSetResult(object):
     def successful(self):
         """Was the taskset successful?
 
-        :returns: ``True`` if all of the tasks in the taskset finished
+        :returns: :const:`True` if all of the tasks in the taskset finished
             successfully (i.e. did not raise an exception).
 
         """
@@ -220,7 +221,7 @@ class TaskSetResult(object):
     def failed(self):
         """Did the taskset fail?
 
-        :returns: ``True`` if any of the tasks in the taskset failed.
+        :returns: :const:`True` if any of the tasks in the taskset failed.
             (i.e., raised an exception)
 
         """
@@ -230,7 +231,7 @@ class TaskSetResult(object):
     def waiting(self):
         """Is the taskset waiting?
 
-        :returns: ``True`` if any of the tasks in the taskset is still
+        :returns: :const:`True` if any of the tasks in the taskset is still
             waiting for execution.
 
         """
@@ -240,7 +241,7 @@ class TaskSetResult(object):
     def ready(self):
         """Is the task ready?
 
-        :returns: ``True`` if all of the tasks in the taskset has been
+        :returns: :const:`True` if all of the tasks in the taskset has been
             executed.
 
         """
@@ -308,8 +309,9 @@ class TaskSetResult(object):
         :keyword timeout: The time in seconds, how long
             it will wait for results, before the operation times out.
 
-        :raises celery.exceptions.TimeoutError: if ``timeout`` is not ``None``
-            and the operation takes longer than ``timeout`` seconds.
+        :raises celery.exceptions.TimeoutError: if ``timeout`` is not
+            :const:`None` and the operation takes longer than ``timeout``
+            seconds.
 
         If any of the tasks raises an exception, the exception
         will be reraised by :meth:`join`.
@@ -377,11 +379,11 @@ class EagerResult(BaseAsyncResult):
         self._traceback = traceback
 
     def successful(self):
-        """Returns ``True`` if the task executed without failure."""
+        """Returns :const:`True` if the task executed without failure."""
         return self.status == states.SUCCESS
 
     def ready(self):
-        """Returns ``True`` if the task has been executed."""
+        """Returns :const:`True` if the task has been executed."""
         return True
 
     def wait(self, timeout=None):

+ 1 - 1
celery/serialization.py

@@ -55,7 +55,7 @@ def find_nearest_pickleable_exception(exc):
     :param exc: An exception instance.
 
     :returns: the nearest exception if it's not :exc:`Exception` or below,
-        if it is it returns ``None``.
+        if it is it returns :const:`None`.
 
     :rtype :exc:`Exception`:
 

+ 21 - 20
celery/task/base.py

@@ -95,7 +95,7 @@ class BaseTask(object):
 
     .. attribute:: abstract
 
-        If ``True`` the task is an abstract base class.
+        If :const:`True` the task is an abstract base class.
 
     .. attribute:: type
 
@@ -104,7 +104,7 @@ class BaseTask(object):
     .. attribute:: queue
 
         Select a destination queue for this task. The queue needs to exist
-        in ``CELERY_QUEUES``. The ``routing_key``, ``exchange`` and
+        in :setting:`CELERY_QUEUES`. The ``routing_key``, ``exchange`` and
         ``exchange_type`` attributes will be ignored if this is set.
 
     .. attribute:: routing_key
@@ -144,7 +144,7 @@ class BaseTask(object):
     .. attribute:: max_retries
 
         Maximum number of retries before giving up.
-        If set to ``None``, it will never stop retrying.
+        If set to :const:`None`, it will never stop retrying.
 
     .. attribute:: default_retry_delay
 
@@ -153,9 +153,9 @@ class BaseTask(object):
 
     .. attribute:: rate_limit
 
-        Set the rate limit for this task type, Examples: ``None`` (no rate
-        limit), ``"100/s"`` (hundred tasks a second), ``"100/m"`` (hundred
-        tasks a minute), ``"100/h"`` (hundred tasks an hour)
+        Set the rate limit for this task type, Examples: :const:`None` (no
+        rate limit), ``"100/s"`` (hundred tasks a second), ``"100/m"``
+        (hundred tasks a minute), ``"100/h"`` (hundred tasks an hour)
 
     .. attribute:: ignore_result
 
@@ -186,12 +186,12 @@ class BaseTask(object):
 
     .. attribute:: autoregister
 
-        If ``True`` the task is automatically registered in the task
+        If :const:`True` the task is automatically registered in the task
         registry, which is the default behaviour.
 
     .. attribute:: track_started
 
-        If ``True`` the task will report its status as "started"
+        If :const:`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,
@@ -202,11 +202,11 @@ class BaseTask(object):
         currently running.
 
         The global default can be overridden with the
-        ``CELERY_TRACK_STARTED`` setting.
+        :setting:`CELERY_TRACK_STARTED` setting.
 
     .. attribute:: acks_late
 
-        If set to ``True`` messages for this task will be acknowledged
+        If set to :vonst:`True` messages for this task will be acknowledged
         **after** the task has been executed, not *just before*, which is
         the default behavior.
 
@@ -214,7 +214,7 @@ class BaseTask(object):
         crashes in the middle of execution, which may be acceptable for some
         applications.
 
-        The global default can be overriden by the ``CELERY_ACKS_LATE``
+        The global default can be overriden by the :setting:`CELERY_ACKS_LATE`
         setting.
 
     """
@@ -536,7 +536,7 @@ class BaseTask(object):
         :param args: positional arguments passed on to the task.
         :param kwargs: keyword arguments passed on to the task.
         :keyword throw: Re-raise task exceptions. Defaults to
-            the ``CELERY_EAGER_PROPAGATES_EXCEPTIONS`` setting.
+            the :setting:`CELERY_EAGER_PROPAGATES_EXCEPTIONS` setting.
 
         :rtype :class:`celery.result.EagerResult`:
 
@@ -733,7 +733,7 @@ class PeriodicTask(Task):
 
     .. attribute:: relative
 
-        If set to ``True``, run times are relative to the time when the
+        If set to :const:`True`, run times are relative to the time when the
         server was started. This was the previous behaviour, periodic tasks
         are now scheduled by the clock.
 
@@ -824,13 +824,14 @@ class PeriodicTask(Task):
         * ``(False, 12)``, means the task should be run in 12 seconds.
 
         You can override this to decide the interval at runtime,
-        but keep in mind the value of ``CELERYBEAT_MAX_LOOP_INTERVAL``, which
-        decides the maximum number of seconds celerybeat can sleep between
-        re-checking the periodic task intervals. So if you dynamically change
-        the next run at value, and the max interval is set to 5 minutes, it
-        will take 5 minutes for the change to take effect, so you may
-        consider lowering the value of ``CELERYBEAT_MAX_LOOP_INTERVAL`` if
-        responsiveness if of importance to you.
+        but keep in mind the value of :setting:`CELERYBEAT_MAX_LOOP_INTERVAL`,
+        which decides the maximum number of seconds celerybeat can sleep
+        between re-checking the periodic task intervals.  So if you
+        dynamically change the next run at value, and the max interval is
+        set to 5 minutes, it will take 5 minutes for the change to take
+        effect, so you may consider lowering the value of
+        :setting:`CELERYBEAT_MAX_LOOP_INTERVAL` if responsiveness is of
+        importance to you.
 
         """
         return self.run_every.is_due(last_run_at)

+ 4 - 4
celery/utils/__init__.py

@@ -119,7 +119,7 @@ def kwdict(kwargs):
 
 def first(predicate, iterable):
     """Returns the first element in ``iterable`` that ``predicate`` returns a
-    ``True`` value for."""
+    :const:`True` value for."""
     for item in iterable:
         if predicate(item):
             return item
@@ -204,13 +204,13 @@ def is_iterable(obj):
 
 
 def mitemgetter(*items):
-    """Like :func:`operator.itemgetter` but returns ``None`` on missing items
-    instead of raising :exc:`KeyError`."""
+    """Like :func:`operator.itemgetter` but returns :const:`None`
+    on missing items instead of raising :exc:`KeyError`."""
     return lambda container: map(container.get, items)
 
 
 def mattrgetter(*attrs):
-    """Like :func:`operator.itemgetter` but returns ``None`` on missing
+    """Like :func:`operator.itemgetter` but returns :const:`None` on missing
     attributes instead of raising :exc:`AttributeError`."""
     return lambda obj: dict((attr, getattr(obj, attr, None))
                                 for attr in attrs)

+ 4 - 4
celery/utils/dispatch/signal.py

@@ -45,8 +45,8 @@ class Signal(object):
         :param receiver: A function or an instance method which is to
             receive signals. Receivers must be hashable objects.
 
-            if weak is ``True``, then receiver must be weak-referencable (more
-            precisely :func:`saferef.safe_ref()` must be able to create a
+            if weak is :const:`True`, then receiver must be weak-referencable
+            (more precisely :func:`saferef.safe_ref()` must be able to create a
             reference to the receiver).
 
             Receivers must be able to accept keyword arguments.
@@ -56,7 +56,7 @@ class Signal(object):
             ``dispatch_uid``.
 
         :keyword sender: The sender to which the receiver should respond.
-            Must either be of type :class:`Signal`, or ``None`` to receive
+            Must either be of type :class:`Signal`, or :const:`None` to receive
             events from any sender.
 
         :keyword weak: Whether to use weak references to the receiver.
@@ -121,7 +121,7 @@ class Signal(object):
         have all receivers called if a raises an error.
 
         :param sender: The sender of the signal. Either a specific
-            object or ``None``.
+            object or :const:`None`.
 
         :keyword \*\*named: Named arguments which will be passed to receivers.
 

+ 1 - 1
celery/utils/timeutils.py

@@ -63,7 +63,7 @@ def remaining(start, ends_in, now=None, relative=True):
 
     :param start: Start :class:`~datetime.datetime`.
     :param ends_in: The end delta as a :class:`~datetime.timedelta`.
-    :keyword relative: If set to ``False``, the end time will be calculated
+    :keyword relative: If set to :const:`False`, the end time will be calculated
         using :func:`delta_resolution` (i.e. rounded to the resolution
           of ``ends_in``).
     :keyword now: The current time, defaults to :func:`datetime.now`.

+ 58 - 0
celery/worker/__init__.py

@@ -50,6 +50,64 @@ def process_initializer(app):
 
 
 class WorkController(object):
+    """Executes tasks waiting in the task queue.
+
+    :param concurrency: see :attr:`concurrency`.
+    :param logfile: see :attr:`logfile`.
+    :param loglevel: see :attr:`loglevel`.
+    :param embed_clockservice: see :attr:`embed_clockservice`.
+    :param send_events: see :attr:`send_events`.
+
+    .. attribute:: concurrency
+
+        The number of simultaneous processes doing work (default:
+        ``conf.CELERYD_CONCURRENCY``)
+
+    .. attribute:: loglevel
+
+        The loglevel used (default: :const:`logging.INFO`)
+
+    .. attribute:: logfile
+
+        The logfile used, if no logfile is specified it uses ``stderr``
+        (default: `celery.conf.CELERYD_LOG_FILE`).
+
+    .. attribute:: embed_clockservice
+
+        If :const:`True`, celerybeat is embedded, running in the main worker
+        process as a thread.
+
+    .. attribute:: send_events
+
+        Enable the sending of monitoring events, these events can be captured
+        by monitors (celerymon).
+
+    .. attribute:: logger
+
+        The :class:`logging.Logger` instance used for logging.
+
+    .. attribute:: pool
+
+        The :class:`multiprocessing.Pool` instance used.
+
+    .. attribute:: ready_queue
+
+        The :class:`Queue.Queue` that holds tasks ready for immediate
+        processing.
+
+    .. attribute:: schedule_controller
+
+        Instance of :class:`celery.worker.controllers.ScheduleController`.
+
+    .. attribute:: mediator
+
+        Instance of :class:`celery.worker.controllers.Mediator`.
+
+    .. attribute:: listener
+
+        Instance of :class:`CarrotListener`.
+
+    """
     loglevel = logging.ERROR
     _state = None
     _running = 0

+ 2 - 2
celery/worker/job.py

@@ -180,7 +180,7 @@ class TaskRequest(object):
 
     .. attribute:: executed
 
-        Set to ``True`` if the task has been executed.
+        Set to :const:`True` if the task has been executed.
         A task should only be executed once.
 
     .. attribute:: delivery_info
@@ -190,7 +190,7 @@ class TaskRequest(object):
 
     .. attribute:: acknowledged
 
-        Set to ``True`` if the task has been acknowledged.
+        Set to :const:`True` if the task has been acknowledged.
 
     """
     # Logging output