forked from celery/celery
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ | |
introduction | ||
brokers/index | ||
first-steps-with-celery | ||
next-steps | ||
resources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
============ | ||
Next Steps | ||
============ | ||
|
||
The :ref:`first-steps` guide is intentionally minimal. In this guide | ||
we will demonstrate what Celery offers in more detail, including | ||
how to add Celery support for your application and library. | ||
|
||
|
||
Our Project | ||
=========== | ||
|
||
Project layout:: | ||
|
||
proj/__init__.py | ||
/celery.py | ||
/tasks.py | ||
|
||
:file:`proj/celery.py` | ||
|
||
.. literalinclude:: ../../examples/next-steps/proj/celery.py | ||
:language python: | ||
|
||
|
||
:file:`proj/tasks.py` | ||
|
||
.. literalinclude:: ../../examples/next-steps/proj/tasks.py | ||
:language python: | ||
|
||
|
||
|
||
Subtasks | ||
======== | ||
|
||
|
||
group | ||
----- | ||
|
||
.. code-block:: python | ||
>>> from celery import group | ||
>>> from proj.tasks import add | ||
>>> ~group(add.s(i, i) for i in xrange(10)) | ||
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18] | ||
>>> group(add.s(i, i) for i in xrange(10)).skew(1, 10) | ||
map/starmap | ||
------------- | ||
|
||
.. code-block:: python | ||
>>> from proj.tasks import add | ||
>>> ~xsum.map([range(10), range(100)]) | ||
[45, 4950] | ||
>>> ~add.starmap(zip(range(10), range(10))) | ||
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18] | ||
>>> add.starmap(zip(range(10), range(10))).apply_async(countdown=10) | ||
chunks | ||
------ | ||
|
||
.. code-block:: python | ||
>>> from proj.tasks import add | ||
>>> ~add.chunks(zip(range(100), range(100)), 10) | ||
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from __future__ import absolute_import | ||
|
||
from celery import Celery | ||
|
||
celery = Celery("proj", broker="amqp://", backend="amqp") | ||
celery.conf.CELERY_IMPORTS = ("proj.tasks", ) | ||
|
||
if __name__ == "__main__": | ||
from billiard import freeze_support | ||
freeze_support() | ||
celery.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from __future__ import absolute_import | ||
|
||
from proj.celery import celery | ||
|
||
|
||
@celery.task | ||
def add(x, y): | ||
return x + y | ||
|
||
|
||
@celery.task | ||
def mul(x, y): | ||
return x * y | ||
|
||
|
||
@celery.task | ||
def xsum(numbers): | ||
return sum(numbers) |