File: README.rst

package info (click to toggle)
celery 5.6.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,572 kB
  • sloc: python: 66,917; sh: 795; makefile: 378
file content (40 lines) | stat: -rw-r--r-- 1,382 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
==============================
 Example Celery->HTTP Gateway
==============================

This is an example service exposing the ability to apply tasks and query
statuses/results over HTTP.

Some familiarity with Django is recommended.

`settings.py` contains the celery settings, you probably want to configure
at least the broker related settings.

To run the service you have to run the following commands::

    $ python manage.py syncdb # (if running the database backend)

    $ python manage.py runserver


The service is now running at http://localhost:8000


You can apply tasks, with the `/apply/<task_name>` URL::

    $ curl http://localhost:8000/apply/celery.ping/
    {"ok": "true", "task_id": "e3a95109-afcd-4e54-a341-16c18fddf64b"}

Then you can use the resulting task-id to get the return value::

    $ curl http://localhost:8000/e3a95109-afcd-4e54-a341-16c18fddf64b/status/
    {"task": {"status": "SUCCESS", "result": "pong", "id": "e3a95109-afcd-4e54-a341-16c18fddf64b"}}


If you don't want to expose all tasks there're a few possible
approaches. For instance you can extend the `apply` view to only
accept a white-list. Another possibility is to just make views for every task you want to
expose. We made on such view for ping in `views.ping`::

    $ curl http://localhost:8000/ping/
    {"ok": "true", "task_id": "383c902c-ba07-436b-b0f3-ea09cc22107c"}