FAQ 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. .. _faq:
  2. ============================
  3. Frequently Asked Questions
  4. ============================
  5. .. contents::
  6. :local:
  7. .. _faq-general:
  8. General
  9. =======
  10. .. _faq-when-to-use:
  11. What kinds of things should I use Celery for?
  12. ---------------------------------------------
  13. **Answer:** `Queue everything and delight everyone`_ is a good article
  14. describing why you would use a queue in a web context.
  15. .. _`Queue everything and delight everyone`:
  16. http://decafbad.com/blog/2008/07/04/queue-everything-and-delight-everyone
  17. These are some common use cases:
  18. * Running something in the background. For example, to finish the web request
  19. as soon as possible, then update the users page incrementally.
  20. This gives the user the impression of good performance and "snappiness", even
  21. though the real work might actually take some time.
  22. * Running something after the web request has finished.
  23. * Making sure something is done, by executing it asynchronously and using
  24. retries.
  25. * Scheduling periodic work.
  26. And to some degree:
  27. * Distributed computing.
  28. * Parallel execution.
  29. .. _faq-misconceptions:
  30. Misconceptions
  31. ==============
  32. .. _faq-serializion-is-a-choice:
  33. Is Celery dependent on pickle?
  34. ------------------------------
  35. **Answer:** No.
  36. Celery can support any serialization scheme and has built-in support for
  37. JSON, YAML, Pickle and msgpack. Also, as every task is associated with a
  38. content type, you can even send one task using pickle, and another using JSON.
  39. The default serialization format is pickle simply because it is
  40. convenient (it supports sending complex Python objects as task arguments).
  41. If you need to communicate with other languages you should change
  42. to a serialization format that is suitable for that.
  43. You can set a global default serializer, the default serializer for a
  44. particular Task, or even what serializer to use when sending a single task
  45. instance.
  46. .. _faq-is-celery-for-django-only:
  47. Is Celery for Django only?
  48. --------------------------
  49. **Answer:** No.
  50. Celery does not depend on Django anymore. To use Celery with Django you have
  51. to use the `django-celery`_ package.
  52. .. _`django-celery`: http://pypi.python.org/pypi/django-celery
  53. .. _faq-is-celery-for-rabbitmq-only:
  54. Do I have to use AMQP/RabbitMQ?
  55. -------------------------------
  56. **Answer**: No.
  57. You can also use Redis, Beanstalk, CouchDB, MongoDB or an SQL database,
  58. see :ref:`brokers`.
  59. These "virtual transports" may have limited broadcast and event functionality.
  60. For example remote control commands only works with AMQP and Redis.
  61. Redis or a database won't perform as well as
  62. an AMQP broker. If you have strict reliability requirements you are
  63. encouraged to use RabbitMQ or another AMQP broker. Redis/database also use
  64. polling, so they are likely to consume more resources. However, if you for
  65. some reason are not able to use AMQP, feel free to use these alternatives.
  66. They will probably work fine for most use cases, and note that the above
  67. points are not specific to Celery; If using Redis/database as a queue worked
  68. fine for you before, it probably will now. You can always upgrade later
  69. if you need to.
  70. .. _faq-is-celery-multilingual:
  71. Is Celery multilingual?
  72. ------------------------
  73. **Answer:** Yes.
  74. :mod:`~celery.bin.celeryd` is an implementation of Celery in Python. If the
  75. language has an AMQP client, there shouldn't be much work to create a worker
  76. in your language. A Celery worker is just a program connecting to the broker
  77. to process messages.
  78. Also, there's another way to be language independent, and that is to use REST
  79. tasks, instead of your tasks being functions, they're URLs. With this
  80. information you can even create simple web servers that enable preloading of
  81. code. See: `User Guide: Remote Tasks`_.
  82. .. _`User Guide: Remote Tasks`:
  83. http://celery.github.com/celery/userguide/remote-tasks.html
  84. .. _faq-troubleshooting:
  85. Troubleshooting
  86. ===============
  87. .. _faq-mysql-deadlocks:
  88. MySQL is throwing deadlock errors, what can I do?
  89. -------------------------------------------------
  90. **Answer:** MySQL has default isolation level set to `REPEATABLE-READ`,
  91. if you don't really need that, set it to `READ-COMMITTED`.
  92. You can do that by adding the following to your :file:`my.cnf`::
  93. [mysqld]
  94. transaction-isolation = READ-COMMITTED
  95. For more information about InnoDB`s transaction model see `MySQL - The InnoDB
  96. Transaction Model and Locking`_ in the MySQL user manual.
  97. (Thanks to Honza Kral and Anton Tsigularov for this solution)
  98. .. _`MySQL - The InnoDB Transaction Model and Locking`: http://dev.mysql.com/doc/refman/5.1/en/innodb-transaction-model.html
  99. .. _faq-worker-hanging:
  100. celeryd is not doing anything, just hanging
  101. --------------------------------------------
  102. **Answer:** See `MySQL is throwing deadlock errors, what can I do?`_.
  103. or `Why is Task.delay/apply\* just hanging?`.
  104. .. _faq-results-unreliable:
  105. Task results aren't reliably returning
  106. --------------------------------------
  107. **Answer:** If you're using the database backend for results, and in particular
  108. using MySQL, see `MySQL is throwing deadlock errors, what can I do?`_.
  109. .. _faq-publish-hanging:
  110. Why is Task.delay/apply\*/celeryd just hanging?
  111. -----------------------------------------------
  112. **Answer:** There is a bug in some AMQP clients that will make it hang if
  113. it's not able to authenticate the current user, the password doesn't match or
  114. the user does not have access to the virtual host specified. Be sure to check
  115. your broker logs (for RabbitMQ that is :file:`/var/log/rabbitmq/rabbit.log` on
  116. most systems), it usually contains a message describing the reason.
  117. .. _faq-celeryd-on-freebsd:
  118. Does it work on FreeBSD?
  119. ------------------------
  120. **Answer:** The multiprocessing pool requires a working POSIX semaphore
  121. implementation which isn't enabled in FreeBSD by default. You have to enable
  122. POSIX semaphores in the kernel and manually recompile multiprocessing.
  123. Luckily, Viktor Petersson has written a tutorial to get you started with
  124. Celery on FreeBSD here:
  125. http://www.playingwithwire.com/2009/10/how-to-get-celeryd-to-work-on-freebsd/
  126. .. _faq-duplicate-key-errors:
  127. I'm having `IntegrityError: Duplicate Key` errors. Why?
  128. ---------------------------------------------------------
  129. **Answer:** See `MySQL is throwing deadlock errors, what can I do?`_.
  130. Thanks to howsthedotcom.
  131. .. _faq-worker-stops-processing:
  132. Why aren't my tasks processed?
  133. ------------------------------
  134. **Answer:** With RabbitMQ you can see how many consumers are currently
  135. receiving tasks by running the following command::
  136. $ rabbitmqctl list_queues -p <myvhost> name messages consumers
  137. Listing queues ...
  138. celery 2891 2
  139. This shows that there's 2891 messages waiting to be processed in the task
  140. queue, and there are two consumers processing them.
  141. One reason that the queue is never emptied could be that you have a stale
  142. worker process taking the messages hostage. This could happen if celeryd
  143. wasn't properly shut down.
  144. When a message is received by a worker the broker waits for it to be
  145. acknowledged before marking the message as processed. The broker will not
  146. re-send that message to another consumer until the consumer is shut down
  147. properly.
  148. If you hit this problem you have to kill all workers manually and restart
  149. them::
  150. ps auxww | grep celeryd | awk '{print $2}' | xargs kill
  151. You might have to wait a while until all workers have finished the work they're
  152. doing. If it's still hanging after a long time you can kill them by force
  153. with::
  154. ps auxww | grep celeryd | awk '{print $2}' | xargs kill -9
  155. .. _faq-task-does-not-run:
  156. Why won't my Task run?
  157. ----------------------
  158. **Answer:** There might be syntax errors preventing the tasks module being imported.
  159. You can find out if Celery is able to run the task by executing the
  160. task manually:
  161. >>> from myapp.tasks import MyPeriodicTask
  162. >>> MyPeriodicTask.delay()
  163. Watch celeryd`s log file to see if it's able to find the task, or if some
  164. other error is happening.
  165. .. _faq-periodic-task-does-not-run:
  166. Why won't my periodic task run?
  167. -------------------------------
  168. **Answer:** See `Why won't my Task run?`_.
  169. .. _faq-purge-the-queue:
  170. How do I purge all waiting tasks?
  171. ---------------------------------
  172. **Answer:** You can use celeryctl to purge all configured task queues::
  173. $ celeryctl purge
  174. or programatically::
  175. >>> from celery import current_app as celery
  176. >>> celery.control.purge()
  177. 1753
  178. If you only want to purge messages from a specific queue
  179. you have to use the AMQP API or the :program:`camqadm` utility::
  180. $ camqadm queue.purge <queue name>
  181. The number 1753 is the number of messages deleted.
  182. You can also start :mod:`~celery.bin.celeryd` with the
  183. :option:`--purge` argument, to purge messages when the worker starts.
  184. .. _faq-messages-left-after-purge:
  185. I've purged messages, but there are still messages left in the queue?
  186. ---------------------------------------------------------------------
  187. **Answer:** Tasks are acknowledged (removed from the queue) as soon
  188. as they are actually executed. After the worker has received a task, it will
  189. take some time until it is actually executed, especially if there are a lot
  190. of tasks already waiting for execution. Messages that are not acknowledged are
  191. held on to by the worker until it closes the connection to the broker (AMQP
  192. server). When that connection is closed (e.g. because the worker was stopped)
  193. the tasks will be re-sent by the broker to the next available worker (or the
  194. same worker when it has been restarted), so to properly purge the queue of
  195. waiting tasks you have to stop all the workers, and then purge the tasks
  196. using :func:`celery.control.purge`.
  197. .. _faq-results:
  198. Results
  199. =======
  200. .. _faq-get-result-by-task-id:
  201. How do I get the result of a task if I have the ID that points there?
  202. ----------------------------------------------------------------------
  203. **Answer**: Use `Task.AsyncResult`::
  204. >>> result = MyTask.AsyncResult(task_id)
  205. >>> result.get()
  206. This will give you a :class:`~celery.result.BaseAsyncResult` instance
  207. using the tasks current result backend.
  208. If you need to specify a custom result backend you should use
  209. :class:`celery.result.BaseAsyncResult` directly::
  210. >>> from celery.result import BaseAsyncResult
  211. >>> result = BaseAsyncResult(task_id, backend=...)
  212. >>> result.get()
  213. .. _faq-security:
  214. Security
  215. ========
  216. Isn't using `pickle` a security concern?
  217. ----------------------------------------
  218. **Answer**: Yes, indeed it is.
  219. You are right to have a security concern, as this can indeed be a real issue.
  220. It is essential that you protect against unauthorized
  221. access to your broker, databases and other services transmitting pickled
  222. data.
  223. For the task messages you can set the :setting:`CELERY_TASK_SERIALIZER`
  224. setting to "json" or "yaml" instead of pickle. There is
  225. currently no alternative solution for task results (but writing a
  226. custom result backend using JSON is a simple task)
  227. Note that this is not just something you should be aware of with Celery, for
  228. example also Django uses pickle for its cache client.
  229. Can messages be encrypted?
  230. --------------------------
  231. **Answer**: Some AMQP brokers supports using SSL (including RabbitMQ).
  232. You can enable this using the :setting:`BROKER_USE_SSL` setting.
  233. It is also possible to add additional encryption and security to messages,
  234. if you have a need for this then you should contact the :ref:`mailing-list`.
  235. Is it safe to run :program:`celeryd` as root?
  236. ---------------------------------------------
  237. **Answer**: No!
  238. We're not currently aware of any security issues, but it would
  239. be incredibly naive to assume that they don't exist, so running
  240. the Celery services (:program:`celeryd`, :program:`celerybeat`,
  241. :program:`celeryev`, etc) as an unprivileged user is recommended.
  242. .. _faq-brokers:
  243. Brokers
  244. =======
  245. Why is RabbitMQ crashing?
  246. -------------------------
  247. **Answer:** RabbitMQ will crash if it runs out of memory. This will be fixed in a
  248. future release of RabbitMQ. please refer to the RabbitMQ FAQ:
  249. http://www.rabbitmq.com/faq.html#node-runs-out-of-memory
  250. .. note::
  251. This is no longer the case, RabbitMQ versions 2.0 and above
  252. includes a new persister, that is tolerant to out of memory
  253. errors. RabbitMQ 2.1 or higher is recommended for Celery.
  254. If you're still running an older version of RabbitMQ and experience
  255. crashes, then please upgrade!
  256. Misconfiguration of Celery can eventually lead to a crash
  257. on older version of RabbitMQ. Even if it doesn't crash, this
  258. can still consume a lot of resources, so it is very
  259. important that you are aware of the common pitfalls.
  260. * Events.
  261. Running :mod:`~celery.bin.celeryd` with the :option:`-E`/:option:`--events`
  262. option will send messages for events happening inside of the worker.
  263. Events should only be enabled if you have an active monitor consuming them,
  264. or if you purge the event queue periodically.
  265. * AMQP backend results.
  266. When running with the AMQP result backend, every task result will be sent
  267. as a message. If you don't collect these results, they will build up and
  268. RabbitMQ will eventually run out of memory.
  269. Results expire after 1 day by default. It may be a good idea
  270. to lower this value by configuring the :setting:`CELERY_TASK_RESULT_EXPIRES`
  271. setting.
  272. If you don't use the results for a task, make sure you set the
  273. `ignore_result` option:
  274. .. code-block python
  275. @celery.task(ignore_result=True)
  276. def mytask():
  277. ...
  278. class MyTask(Task):
  279. ignore_result = True
  280. .. _faq-use-celery-with-stomp:
  281. Can I use Celery with ActiveMQ/STOMP?
  282. -------------------------------------
  283. **Answer**: No. It used to be supported by Carrot,
  284. but is not currently supported in Kombu.
  285. .. _faq-non-amqp-missing-features:
  286. What features are not supported when not using an AMQP broker?
  287. --------------------------------------------------------------
  288. This is an incomplete list of features not available when
  289. using the virtual transports:
  290. * Remote control commands (supported only by Redis).
  291. * Monitoring with events may not work in all virtual transports.
  292. * The `header` and `fanout` exchange types
  293. (`fanout` is supported by Redis).
  294. .. _faq-tasks:
  295. Tasks
  296. =====
  297. .. _faq-tasks-connection-reuse:
  298. How can I reuse the same connection when applying tasks?
  299. --------------------------------------------------------
  300. **Answer**: See the :setting:`BROKER_POOL_LIMIT` setting.
  301. The connection pool is enabled by default since version 2.5.
  302. .. _faq-sudo-subprocess:
  303. Sudo in a :mod:`subprocess` returns :const:`None`
  304. -------------------------------------------------
  305. There is a sudo configuration option that makes it illegal for process
  306. without a tty to run sudo::
  307. Defaults requiretty
  308. If you have this configuration in your :file:`/etc/sudoers` file then
  309. tasks will not be able to call sudo when celeryd is running as a daemon.
  310. If you want to enable that, then you need to remove the line from sudoers.
  311. See: http://timelordz.com/wiki/Apache_Sudo_Commands
  312. .. _faq-deletes-unknown-tasks:
  313. Why do workers delete tasks from the queue if they are unable to process them?
  314. ------------------------------------------------------------------------------
  315. **Answer**:
  316. The worker rejects unknown tasks, messages with encoding errors and messages
  317. that doesn't contain the proper fields (as per the task message protocol).
  318. If it did not reject them they could be redelivered again and again,
  319. causing a loop.
  320. Recent versions of RabbitMQ has the ability to configure a dead-letter
  321. queue for exchange, so that rejected messages is moved there.
  322. .. _faq-execute-task-by-name:
  323. Can I execute a task by name?
  324. -----------------------------
  325. **Answer**: Yes. Use :func:`celery.execute.send_task`.
  326. You can also execute a task by name from any language
  327. that has an AMQP client.
  328. >>> from celery.execute import send_task
  329. >>> send_task("tasks.add", args=[2, 2], kwargs={})
  330. <AsyncResult: 373550e8-b9a0-4666-bc61-ace01fa4f91d>
  331. .. _faq-get-current-task-id:
  332. How can I get the task id of the current task?
  333. ----------------------------------------------
  334. **Answer**: The current id and more is available in the task request::
  335. @celery.task
  336. def mytask():
  337. cache.set(mytask.request.id, "Running")
  338. For more information see :ref:`task-request-info`.
  339. .. _faq-custom-task-ids:
  340. Can I specify a custom task_id?
  341. -------------------------------
  342. **Answer**: Yes. Use the `task_id` argument to :meth:`Task.apply_async`::
  343. >>> task.apply_async(args, kwargs, task_id="...")
  344. Can I use decorators with tasks?
  345. --------------------------------
  346. **Answer**: Yes. But please see note at :ref:`tasks-decorating`.
  347. .. _faq-natural-task-ids:
  348. Can I use natural task ids?
  349. ---------------------------
  350. **Answer**: Yes, but make sure it is unique, as the behavior
  351. for two tasks existing with the same id is undefined.
  352. The world will probably not explode, but at the worst
  353. they can overwrite each others results.
  354. .. _faq-task-callbacks:
  355. How can I run a task once another task has finished?
  356. ----------------------------------------------------
  357. **Answer**: You can safely launch a task inside a task.
  358. Also, a common pattern is to use callback tasks:
  359. .. code-block:: python
  360. @celery.task()
  361. def add(x, y, callback=None):
  362. result = x + y
  363. if callback:
  364. subtask(callback).delay(result)
  365. return result
  366. @celery.task(ignore_result=True)
  367. def log_result(result, **kwargs):
  368. logger = log_result.get_logger(**kwargs)
  369. logger.info("log_result got: %s" % (result, ))
  370. Invocation::
  371. >>> add.delay(2, 2, callback=log_result.subtask())
  372. See :doc:`userguide/tasksets` for more information.
  373. .. _faq-cancel-task:
  374. Can I cancel the execution of a task?
  375. -------------------------------------
  376. **Answer**: Yes. Use `result.revoke`::
  377. >>> result = add.apply_async(args=[2, 2], countdown=120)
  378. >>> result.revoke()
  379. or if you only have the task id::
  380. >>> from celery import current_app as celery
  381. >>> celery.control.revoke(task_id)
  382. .. _faq-node-not-receiving-broadcast-commands:
  383. Why aren't my remote control commands received by all workers?
  384. --------------------------------------------------------------
  385. **Answer**: To receive broadcast remote control commands, every worker node
  386. uses its host name to create a unique queue name to listen to,
  387. so if you have more than one worker with the same host name, the
  388. control commands will be received in round-robin between them.
  389. To work around this you can explicitly set the host name for every worker
  390. using the :option:`--hostname` argument to :mod:`~celery.bin.celeryd`::
  391. $ celeryd --hostname=$(hostname).1
  392. $ celeryd --hostname=$(hostname).2
  393. etc., etc...
  394. .. _faq-task-routing:
  395. Can I send some tasks to only some servers?
  396. --------------------------------------------
  397. **Answer:** Yes. You can route tasks to an arbitrary server using AMQP,
  398. and a worker can bind to as many queues as it wants.
  399. See :doc:`userguide/routing` for more information.
  400. .. _faq-change-periodic-task-interval-at-runtime:
  401. Can I change the interval of a periodic task at runtime?
  402. --------------------------------------------------------
  403. **Answer**: Yes. You can use the Django database scheduler, or you can
  404. override `PeriodicTask.is_due` or turn `PeriodicTask.run_every` into a
  405. property:
  406. .. code-block:: python
  407. class MyPeriodic(PeriodicTask):
  408. def run(self):
  409. # ...
  410. @property
  411. def run_every(self):
  412. return get_interval_from_database(...)
  413. .. _faq-task-priorities:
  414. Does celery support task priorities?
  415. ------------------------------------
  416. **Answer**: No. In theory, yes, as AMQP supports priorities. However
  417. RabbitMQ doesn't implement them yet.
  418. The usual way to prioritize work in Celery, is to route high priority tasks
  419. to different servers. In the real world this may actually work better than per message
  420. priorities. You can use this in combination with rate limiting to achieve a
  421. highly responsive system.
  422. .. _faq-acks_late-vs-retry:
  423. Should I use retry or acks_late?
  424. --------------------------------
  425. **Answer**: Depends. It's not necessarily one or the other, you may want
  426. to use both.
  427. `Task.retry` is used to retry tasks, notably for expected errors that
  428. is catchable with the `try:` block. The AMQP transaction is not used
  429. for these errors: **if the task raises an exception it is still acknowledged!**.
  430. The `acks_late` setting would be used when you need the task to be
  431. executed again if the worker (for some reason) crashes mid-execution.
  432. It's important to note that the worker is not known to crash, and if
  433. it does it is usually an unrecoverable error that requires human
  434. intervention (bug in the worker, or task code).
  435. In an ideal world you could safely retry any task that has failed, but
  436. this is rarely the case. Imagine the following task:
  437. .. code-block:: python
  438. @celery.task()
  439. def process_upload(filename, tmpfile):
  440. # Increment a file count stored in a database
  441. increment_file_counter()
  442. add_file_metadata_to_db(filename, tmpfile)
  443. copy_file_to_destination(filename, tmpfile)
  444. If this crashed in the middle of copying the file to its destination
  445. the world would contain incomplete state. This is not a critical
  446. scenario of course, but you can probably imagine something far more
  447. sinister. So for ease of programming we have less reliability;
  448. It's a good default, users who require it and know what they
  449. are doing can still enable acks_late (and in the future hopefully
  450. use manual acknowledgement)
  451. In addition `Task.retry` has features not available in AMQP
  452. transactions: delay between retries, max retries, etc.
  453. So use retry for Python errors, and if your task is idempotent
  454. combine that with `acks_late` if that level of reliability
  455. is required.
  456. .. _faq-schedule-at-specific-time:
  457. Can I schedule tasks to execute at a specific time?
  458. ---------------------------------------------------
  459. .. module:: celery.task.base
  460. **Answer**: Yes. You can use the `eta` argument of :meth:`Task.apply_async`.
  461. Or to schedule a periodic task at a specific time, use the
  462. :class:`celery.schedules.crontab` schedule behavior:
  463. .. code-block:: python
  464. from celery.schedules import crontab
  465. from celery.task import periodic_task
  466. @periodic_task(run_every=crontab(hour=7, minute=30, day_of_week="mon"))
  467. def every_monday_morning():
  468. print("This is run every Monday morning at 7:30")
  469. .. _faq-safe-worker-shutdown:
  470. How do I shut down `celeryd` safely?
  471. --------------------------------------
  472. **Answer**: Use the :sig:`TERM` signal, and the worker will finish all currently
  473. executing jobs and shut down as soon as possible. No tasks should be lost.
  474. You should never stop :mod:`~celery.bin.celeryd` with the :sig:`KILL` signal
  475. (:option:`-9`), unless you've tried :sig:`TERM` a few times and waited a few
  476. minutes to let it get a chance to shut down. As if you do tasks may be
  477. terminated mid-execution, and they will not be re-run unless you have the
  478. `acks_late` option set (`Task.acks_late` / :setting:`CELERY_ACKS_LATE`).
  479. .. seealso::
  480. :ref:`worker-stopping`
  481. .. _faq-daemonizing:
  482. How do I run celeryd in the background on [platform]?
  483. -----------------------------------------------------
  484. **Answer**: Please see :ref:`daemonizing`.
  485. .. _faq-django:
  486. Django
  487. ======
  488. .. _faq-django-database-tables:
  489. What purpose does the database tables created by django-celery have?
  490. --------------------------------------------------------------------
  491. Several database tables are created by default, these relate to
  492. * Monitoring
  493. When you use the django-admin monitor, the cluster state is written
  494. to the ``TaskState`` and ``WorkerState`` models.
  495. * Periodic tasks
  496. When the database-backed schedule is used the periodic task
  497. schedule is taken from the ``PeriodicTask`` model, there are
  498. also several other helper tables (``IntervalSchedule``,
  499. ``CrontabSchedule``, ``PeriodicTasks``).
  500. * Task results
  501. The database result backend is enabled by default when using django-celery
  502. (this is for historical reasons, and thus for backward compatibility).
  503. The results are stored in the ``TaskMeta`` and ``TaskSetMeta`` models.
  504. *these tables are not created if another result backend is configured*.
  505. .. _faq-windows:
  506. Windows
  507. =======
  508. .. _faq-windows-worker-spawn-loop:
  509. celeryd keeps spawning processes at startup
  510. -------------------------------------------
  511. **Answer**: This is a known issue on Windows.
  512. You have to start celeryd with the command::
  513. $ python -m celery.bin.celeryd
  514. Any additional arguments can be appended to this command.
  515. See http://bit.ly/bo9RSw
  516. .. _faq-windows-worker-embedded-beat:
  517. The `-B` / `--beat` option to celeryd doesn't work?
  518. ----------------------------------------------------------------
  519. **Answer**: That's right. Run `celerybeat` and `celeryd` as separate
  520. services instead.
  521. .. _faq-windows-django-settings:
  522. `django-celery` can't find settings?
  523. --------------------------------------
  524. **Answer**: You need to specify the :option:`--settings` argument to
  525. :program:`manage.py`::
  526. $ python manage.py celeryd start --settings=settings
  527. See http://bit.ly/bo9RSw