protocol.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. Extensions
  39. ==========
  40. Extensions are additional keys in the message body that the worker may or
  41. may not support. If the worker finds an extension key it doesn't support
  42. it should optimally reject the message so another worker gets a chance
  43. to process it.
  44. * taskset
  45. :`string`:
  46. The taskset this task is part of (if any).
  47. * chord
  48. :`subtask`:
  49. .. versionadded:: 2.3
  50. Signifies that this task is one of the header parts of a chord. The value
  51. of this key is the body of the cord that should be executed when all of
  52. the tasks in the header has returned.
  53. * utc
  54. :`bool`:
  55. .. versionadded:: 2.5
  56. If true time uses the UTC timezone, if not the current local timezone
  57. should be used.
  58. * callbacks
  59. :`<list>subtask`:
  60. .. versionadded:: 3.0
  61. A list of subtasks to apply if the task exited successfully.
  62. * errbacks
  63. :`<list>subtask`:
  64. .. versionadded:: 3.0
  65. A list of subtasks to apply if an error occurs while executing the task.
  66. * timeouts
  67. :`tuple`:
  68. .. versionadded:: 3.1
  69. Task execution timeouts. This is a tuple of hard and soft timeouts.
  70. Timeout values are `int` or `float`.
  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. =============== =================================