소스 검색

Added Sphinx crossref type: :signal:

Ask Solem 14 년 전
부모
커밋
c59415bcf7
4개의 변경된 파일131개의 추가작업 그리고 90개의 파일을 삭제
  1. 5 5
      Changelog
  2. 120 84
      celery/signals.py
  3. 5 0
      docs/_ext/celerydocs.py
  4. 1 1
      docs/configuration.rst

+ 5 - 5
Changelog

@@ -591,14 +591,14 @@ News
 
 * Added signals: `beat_init` and `beat_embedded_init`
 
-    * :data:`celery.signals.beat_init`
+    * :signal:`celery.signals.beat_init`
 
         Dispatched when :program:`celerybeat` starts (either standalone or
         embedded).  Sender is the :class:`celery.beat.Service` instance.
 
-    * :data:`celery.signals.beat_embedded_init`
+    * :signal:`celery.signals.beat_embedded_init`
 
-        Dispatched in addition to the :data:`beat_init` signal when
+        Dispatched in addition to the :signal:`beat_init` signal when
         :program:`celerybeat` is started as an embedded process.  Sender
         is the :class:`celery.beat.Service` instance.
 
@@ -1110,7 +1110,7 @@ News
     Unless you configure the loggers manually as shown below, that is.
 
     *Users can choose to configure logging by subscribing to the
-    :data:`~celery.signals.setup_logging` signal:*
+    :signal:`~celery.signals.setup_logging` signal:*
 
     .. code-block:: python
 
@@ -2267,7 +2267,7 @@ News
 * `apply(throw=True)` / :setting:`CELERY_EAGER_PROPAGATES_EXCEPTIONS`:
   Makes eager execution re-raise task errors.
 
-* New signal: :data:`~celery.signals.worker_process_init`: Sent inside the
+* New signal: :signal:`~celery.signals.worker_process_init`: Sent inside the
   pool worker process at init.
 
 * celeryd :option:`-Q` option: Ability to specify list of queues to use,

+ 120 - 84
celery/signals.py

@@ -1,9 +1,10 @@
 """
+==============
 celery.signals
 ==============
 
-Signals allows decoupled applications receive notifications when actions
-occur elsewhere in the framework.
+Signals allows decoupled applications to receive notifications when certain actions
+occur.
 
 :copyright: (c) 2009 - 2011 by Ask Solem.
 :license: BSD, see LICENSE for more details.
@@ -14,12 +15,12 @@ occur elsewhere in the framework.
 .. _signal-basics:
 
 Basics
-------
+======
 
 Several kinds of events trigger signals, you can connect to these signals
 to perform actions as they trigger.
 
-Example connecting to the :data:`task_sent` signal:
+Example connecting to the :signal:`task_sent` signal:
 
 .. code-block:: python
 
@@ -33,7 +34,7 @@ Example connecting to the :data:`task_sent` signal:
 
 
 Some signals also have a sender which you can filter by. For example the
-:data:`task_sent` signal uses the task name as a sender, so you can
+:signal:`task_sent` signal uses the task name as a sender, so you can
 connect your handler to be called only when tasks with name `"tasks.add"`
 has been sent by providing the `sender` argument to
 :class:`~celery.utils.dispatch.signal.Signal.connect`:
@@ -45,135 +46,170 @@ has been sent by providing the `sender` argument to
 .. _signal-ref:
 
 Signals
--------
+=======
 
 Task Signals
-~~~~~~~~~~~~
+------------
+
+.. signal:: task_sent
+
+task_sent
+~~~~~~~~~
+
+Dispatched when a task has been sent to the broker.
+Note that this is executed in the client process, the one sending
+the task, not in the worker.
+
+Sender is the name of the task being sent.
+
+Provides arguments:
+
+* task_id
+    Id of the task to be executed.
+
+* task
+    The task being executed.
+
+* args
+    the tasks positional arguments.
+
+* kwargs
+    The tasks keyword arguments.
 
-.. data:: task_sent
+* eta
+    The time to execute the task.
 
-    Dispatched when a task has been sent to the broker.
-    Note that this is executed in the client process, the one sending
-    the task, not in the worker.
+* taskset
+    Id of the taskset this task is part of (if any).
 
-    Sender is the name of the task being sent.
+.. signal:: task_prerun
 
-    Provides arguments:
+task_prerun
+~~~~~~~~~~~
 
-    * task_id
-        Id of the task to be executed.
+Dispatched before a task is executed.
 
-    * task
-        The task being executed.
+Sender is the task class being executed.
 
-    * args
-        the tasks positional arguments.
+Provides arguments:
 
-    * kwargs
-        The tasks keyword arguments.
+* task_id
+    Id of the task to be executed.
 
-    * eta
-        The time to execute the task.
+* task
+    The task being executed.
 
-    * taskset
-        Id of the taskset this task is part of (if any).
+* args
+    the tasks positional arguments.
 
-.. data:: task_prerun
+* kwargs
+    The tasks keyword arguments.
 
-    Dispatched before a task is executed.
+.. signal:: task_postrun
 
-    Sender is the task class being executed.
+task_postrun
+~~~~~~~~~~~~
 
-    Provides arguments:
+Dispatched after a task has been executed.
 
-    * task_id
-        Id of the task to be executed.
+Sender is the task class executed.
 
-    * task
-        The task being executed.
+Provides arguments:
 
-    * args
-        the tasks positional arguments.
+* task_id
+    Id of the task to be executed.
 
-    * kwargs
-        The tasks keyword arguments.
+* task
+    The task being executed.
 
-.. data:: task_postrun
+* args
+    The tasks positional arguments.
 
-    Dispatched after a task has been executed.
+* kwargs
+    The tasks keyword arguments.
 
-    Sender is the task class executed.
+* retval
+    The return value of the task.
 
-    Provides arguments:
+.. signal:: task_failure
 
-    * task_id
-        Id of the task to be executed.
+task_failure
+~~~~~~~~~~~~
 
-    * task
-        The task being executed.
+Dispatched when a task fails.
 
-    * args
-        The tasks positional arguments.
+Sender is the task class executed.
 
-    * kwargs
-        The tasks keyword arguments.
+Provides arguments:
 
-    * retval
-        The return value of the task.
+* task_id
+    Id of the task.
 
-.. data:: task_failure
+* exception
+    Exception instance raised.
 
-    Dispatched when a task fails.
+* args
+    Positional arguments the task was called with.
 
-    Sender is the task class executed.
+* kwargs
+    Keyword arguments the task was called with.
 
-    Provides arguments:
+* traceback
+    Stack trace object.
 
-    * task_id
-        Id of the task.
-    * exception
-        Exception instance raised.
-    * args
-        Positional arguments the task was called with.
-    * kwargs
-        Keyword arguments the task was called with.
-    * traceback
-        Stack trace object.
-    * einfo
-        The :class:`celery.datastructures.ExceptionInfo` instance.
+* einfo
+    The :class:`celery.datastructures.ExceptionInfo` instance.
 
 Worker Signals
-~~~~~~~~~~~~~~
+--------------
+
+.. signal:: worker_init
 
-.. data:: worker_init
+worker_init
+~~~~~~~~~~~
 
-    Dispatched before the worker is started.
+Dispatched before the worker is started.
+
+.. signal:: worker_ready
+
+worker_ready
+~~~~~~~~~~~~
 
-.. data:: worker_ready
+Dispatched when the worker is ready to accept work.
 
-    Dispatched when the worker is ready to accept work.
+.. signal:: worker_process_init
 
-.. data:: worker_process_init
+worker_process_init
+~~~~~~~~~~~~~~~~~~~
 
-    Dispatched by each new pool worker process when it starts.
+Dispatched by each new pool worker process when it starts.
 
-.. data:: worker_shutdown
+.. signal:: worker_shutdown
 
-    Dispatched when the worker is about to shut down.
+worker_shutdown
+~~~~~~~~~~~~~~~
+
+Dispatched when the worker is about to shut down.
 
 Celerybeat Signals
-~~~~~~~~~~~~~~~~~~
+------------------
+
+.. signal:: beat_init
 
-.. data:: beat_init
+beat_init
+~~~~~~~~~
 
-    Dispatched when celerybeat starts (either standalone or embedded).
-    Sender is the :class:`celery.beat.Service` instance.
+Dispatched when celerybeat starts (either standalone or embedded).
+Sender is the :class:`celery.beat.Service` instance.
 
-.. data:: beat_embedded_init
+.. signal:: beat_embedded_init
+
+beat_embedded_init
+~~~~~~~~~~~~~~~~~~
 
-    Dispatched in addition to the :data:`beat_init` signal when celerybeat is
-    started as an embedded process.  Sender is the
-    :class:`celery.beat.Service` instance.
+Dispatched in addition to the :signal:`beat_init` signal when celerybeat is
+started as an embedded process.  Sender is the
+:class:`celery.beat.Service` instance.
 
 
 """

+ 5 - 0
docs/_ext/celerydocs.py

@@ -19,3 +19,8 @@ def setup(app):
         rolename="control",
         indextemplate="pair: %s; control",
     )
+    app.add_crossref_type(
+        directivename="signal",
+        rolename="signal",
+        indextemplate="pair: %s; signal",
+    )

+ 1 - 1
docs/configuration.rst

@@ -1099,7 +1099,7 @@ this behavior.
 .. note::
 
     Logging can also be customized by connecting to the
-    :data:`celery.signals.setup_logging` signal.
+    :signal:`celery.signals.setup_logging` signal.
 
 .. setting:: CELERYD_LOG_FILE