Commit fd5860ee authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

README: Split installation / setup and usage

Also add a task example with celery.signature
parent ab2bc5785e3f
......@@ -4,8 +4,8 @@ Summary
Run, monitor and log celery tasks.
Installation and setup
Declare tasks using celery task or cubicweb-celery cwtasks.
......@@ -31,11 +31,20 @@ Start a worker::
celery worker -l info -E
Task state synchronization requires to run the `celery-monitor` command::
cubicweb-ctl celery-monitor <instance-name>
Ensure to have the loaded for both cubicweb instance and
celery worker, enforce by settings with CELERY_CONFIG_MODULE environment
variable (it must be an importable python module).
Running tasks
Create a task:
.. code-block:: python
......@@ -64,7 +73,11 @@ Run a task:
start_async_task() accept task names, task objects or task signatures:
For instance, to start the above task in a dedicated queue named `myqueue`:
.. code-block:: python
Task state synchronization require to run the `celery-monitor` command::
import celery
cubicweb-ctl celery-monitor <instance-name>
start_async_task(cnx, celery.signature('hi_there', args=('THERE',),
kwargs={'kw': 42}, queue='myqueue'))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment