Skip to content

Commit 33a1a7d

Browse files
author
Ask Solem
committed
More documentation fixes
1 parent 24b3eb7 commit 33a1a7d

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed

docs/getting-started/first-steps-with-celery.rst

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,24 @@ Our addition task looks like this:
2929
All celery tasks are classes that inherit from the ``Task``
3030
class. In this case we're using a decorator that wraps the add
3131
function in an appropriate class for us automatically. The full
32-
documentation on how to create tasks and task classes are in
33-
:doc:`Executing Tasks<../userguide/tasks>`.
32+
documentation on how to create tasks and task classes is in the
33+
:doc:`../userguide/tasks>` part of the user guide.
3434

3535

3636

3737
Configuration
3838
=============
3939

40-
Celery is configured by using a configuration module. By convention,
41-
this module is called ``celeryconfig.py``. This module must be in the
42-
Python path so it can be imported.
40+
Celery is configured by using a configuration module. By default
41+
this module is called ``celeryconfig.py``.
42+
43+
:Note: This configuration module must be on the Python path so it
44+
can be imported.
4345

4446
You can set a custom name for the configuration module with the
45-
``CELERY_CONFIG_MODULE`` variable. In these examples we use the
47+
``CELERY_CONFIG_MODULE`` variable, but in these examples we use the
4648
default name.
4749

48-
4950
Let's create our ``celeryconfig.py``.
5051

5152
1. Configure how we communicate with the broker::
@@ -61,10 +62,14 @@ Let's create our ``celeryconfig.py``.
6162

6263
CELERY_RESULT_BACKEND = "amqp"
6364

65+
The AMQP backend is non-persistent by default, and you can only
66+
fetch the result of a task once (as it's sent as a message).
67+
6468
3. Finally, we list the modules to import, that is, all the modules
65-
that contain tasks. This is so celery knows about what tasks it can
66-
be asked to perform. We only have a single task module,
67-
``tasks.py``, which we added earlier::
69+
that contain tasks. This is so Celery knows about what tasks it can
70+
be asked to perform.
71+
72+
We only have a single task module, ``tasks.py``, which we added earlier::
6873

6974
CELERY_IMPORTS = ("tasks", )
7075

@@ -101,43 +106,51 @@ For info on how to run celery as standalone daemon, see
101106
Executing the task
102107
==================
103108

104-
Whenever we want to execute our task, we can use the ``delay`` method
105-
of the task class.
109+
Whenever we want to execute our task, we can use the
110+
:meth:`~celery.task.base.Task.delay` method of the task class.
106111

107-
This is a handy shortcut to the ``apply_async`` method which gives
108-
greater control of the task execution.
109-
See :doc:`Executing Tasks<../userguide/executing>` for more information.
112+
This is a handy shortcut to the :meth:`~celery.task.base.Task.apply_async`
113+
method which gives greater control of the task execution. Read the
114+
:doc:`Executing Tasks<../userguide/executing>` part of the user guide
115+
for more information about executing tasks.
110116

111117
>>> from tasks import add
112118
>>> add.delay(4, 4)
113119
<AsyncResult: 889143a6-39a2-4e52-837b-d80d33efb22d>
114120

115121
At this point, the task has been sent to the message broker. The message
116-
broker will hold on to the task until a celery worker server has successfully
122+
broker will hold on to the task until a worker server has successfully
117123
picked it up.
118124

119125
*Note:* If everything is just hanging when you execute ``delay``, please check
120126
that RabbitMQ is running, and that the user/password has access to the virtual
121127
host you configured earlier.
122128

123-
Right now we have to check the celery worker log files to know what happened
124-
with the task. This is because we didn't keep the ``AsyncResult`` object
125-
returned by ``delay``.
129+
Right now we have to check the worker log files to know what happened
130+
with the task. This is because we didn't keep the :class:`~celery.result.AsyncResult`
131+
object returned by :meth:`~celery.task.base.Task.delay`.
126132

127-
The ``AsyncResult`` lets us find the state of the task, wait for the task to
128-
finish and get its return value (or exception if the task failed).
133+
The :class:`~celery.result.AsyncResult` lets us find the state of the task, wait for
134+
the task to finish, get its return value (or exception if the task failed),
135+
and more.
129136

130-
So, let's execute the task again, but this time we'll keep track of the task:
137+
So, let's execute the task again, but this time we'll keep track of the task
138+
by keeping the :class:`~celery.result.AsyncResult`::
131139

132140
>>> result = add.delay(4, 4)
141+
133142
>>> result.ready() # returns True if the task has finished processing.
134143
False
144+
135145
>>> result.result # task is not ready, so no return value yet.
136146
None
147+
137148
>>> result.get() # Waits until the task is done and returns the retval.
138149
8
150+
139151
>>> result.result # direct access to result, doesn't re-raise errors.
140152
8
153+
141154
>>> result.successful() # returns True if the task didn't end in failure.
142155
True
143156

docs/includes/introduction.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
--
1111

12-
Celery is a task queue/job queue based on distributed message passing.
12+
Celery is an asynchronous task queue/job queue based on distributed message passing.
1313
It is focused on real-time operation, but supports scheduling as well.
1414

1515
The execution units, called tasks, are executed concurrently on a single or
@@ -24,8 +24,8 @@ language. It can also `operate with other languages using webhooks`_.
2424
The recommended message broker is `RabbitMQ`_, but support for `Redis`_ and
2525
databases (`SQLAlchemy`_) is also available.
2626

27-
You may also be pleased to know that full Django integration exists
28-
via the `django-celery`_ package.
27+
You may also be pleased to know that full Django integration exists,
28+
delivered by the `django-celery`_ package.
2929

3030
.. _`RabbitMQ`: http://www.rabbitmq.com/
3131
.. _`Redis`: http://code.google.com/p/redis/
@@ -46,7 +46,7 @@ This is a high level overview of the architecture.
4646

4747
The broker pushes tasks to the worker servers.
4848
A worker server is a networked machine running ``celeryd``. This can be one or
49-
more machines, depending on the workload.
49+
more machines depending on the workload.
5050

5151
The result of the task can be stored for later retrieval (called its
5252
"tombstone").

0 commit comments

Comments
 (0)