protocol.rst 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. .. _internals-task-message-protocol:
  2. .. _task-message-protocol-v1:
  3. =======================
  4. Task Messages
  5. =======================
  6. .. contents::
  7. :local:
  8. Message format
  9. ==============
  10. * task
  11. :`string`:
  12. Name of the task. **required**
  13. * id
  14. :`string`:
  15. Unique id of the task (UUID). **required**
  16. * args
  17. :`list`:
  18. List of arguments. Will be an empty list if not provided.
  19. * kwargs
  20. :`dictionary`:
  21. Dictionary of keyword arguments. Will be an empty dictionary if not
  22. provided.
  23. * retries
  24. :`int`:
  25. Current number of times this task has been retried.
  26. Defaults to `0` if not specified.
  27. * eta
  28. :`string` (ISO 8601):
  29. Estimated time of arrival. This is the date and time in ISO 8601
  30. format. If not provided the message is not scheduled, but will be
  31. executed asap.
  32. * expires
  33. :`string` (ISO 8601):
  34. .. versionadded:: 2.0.2
  35. Expiration date. This is the date and time in ISO 8601 format.
  36. If not provided the message will never expire. The message
  37. will be expired when the message is received and the expiration date
  38. has been exceeded.
  39. Extensions
  40. ==========
  41. Extensions are additional keys in the message body that the worker may or
  42. may not support. If the worker finds an extension key it doesn't support
  43. it should optimally reject the message so another worker gets a chance
  44. to process it.
  45. * taskset
  46. :`string`:
  47. The taskset this task is part of (if any).
  48. * chord
  49. :`subtask`:
  50. .. versionadded:: 2.3
  51. Signifies that this task is one of the header parts of a chord. The value
  52. of this key is the body of the cord that should be executed when all of
  53. the tasks in the header has returned.
  54. * utc
  55. :`bool`:
  56. .. versionadded:: 2.5
  57. If true time uses the UTC timezone, if not the current local timezone
  58. should be used.
  59. * callbacks
  60. :`<list>subtask`:
  61. .. versionadded:: 3.0
  62. A list of subtasks to apply if the task exited successfully.
  63. * errbacks
  64. :`<list>subtask`:
  65. .. versionadded:: 3.0
  66. A list of subtasks to apply if an error occurs while executing the task.
  67. * timelimit
  68. :`<tuple>(float, float)`:
  69. .. versionadded:: 3.1
  70. Task execution time limit settings. This is a tuple of hard and soft time
  71. limit value (`int`/`float` or :const:`None` for no limit).
  72. Example value specifying a soft time limit of 3 seconds, and a hard time
  73. limt of 10 seconds::
  74. {'timelimit': (3.0, 10.0)}
  75. Example message
  76. ===============
  77. This is an example invocation of the `celery.task.PingTask` task in JSON
  78. format:
  79. .. code-block:: javascript
  80. {"id": "4cc7438e-afd4-4f8f-a2f3-f46567e7ca77",
  81. "task": "celery.task.PingTask",
  82. "args": [],
  83. "kwargs": {},
  84. "retries": 0,
  85. "eta": "2009-11-17T12:30:56.527191"}
  86. Serialization
  87. =============
  88. Several types of serialization formats are supported using the
  89. `content_type` message header.
  90. The MIME-types supported by default are shown in the following table.
  91. =============== =================================
  92. Scheme MIME Type
  93. =============== =================================
  94. json application/json
  95. yaml application/x-yaml
  96. pickle application/x-python-serialize
  97. msgpack application/x-msgpack
  98. =============== =================================