protocol.rst 3.1 KB

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