protocol.rst 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. * timelimit
  67. :`<tuple>(float, float)`:
  68. .. versionadded:: 3.1
  69. Task execution time limit settings. This is a tuple of hard and soft time
  70. limit value (`int`/`float` or :const:`None` for no limit).
  71. Example value specifying a soft time limit of 3 seconds, and a hard time
  72. limt of 10 seconds::
  73. {'timelimit': (3.0, 10.0)}
  74. Example message
  75. ===============
  76. This is an example invocation of the `celery.task.PingTask` task in JSON
  77. format:
  78. .. code-block:: javascript
  79. {"id": "4cc7438e-afd4-4f8f-a2f3-f46567e7ca77",
  80. "task": "celery.task.PingTask",
  81. "args": [],
  82. "kwargs": {},
  83. "retries": 0,
  84. "eta": "2009-11-17T12:30:56.527191"}
  85. Serialization
  86. =============
  87. Several types of serialization formats are supported using the
  88. `content_type` message header.
  89. The MIME-types supported by default are shown in the following table.
  90. =============== =================================
  91. Scheme MIME Type
  92. =============== =================================
  93. json application/json
  94. yaml application/x-yaml
  95. pickle application/x-python-serialize
  96. msgpack application/x-msgpack
  97. =============== =================================