faq.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Frequently Asked Questions &mdash; Celery v0.7.0 (unstable) documentation</title>
  7. <link rel="stylesheet" href="static/nature.css" type="text/css" />
  8. <link rel="stylesheet" href="static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '',
  12. VERSION: '0.7.0 (unstable)',
  13. COLLAPSE_MODINDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="static/jquery.js"></script>
  19. <script type="text/javascript" src="static/doctools.js"></script>
  20. <link rel="top" title="Celery v0.7.0 (unstable) documentation" href="index.html" />
  21. <link rel="next" title="Module API Reference" href="reference/index.html" />
  22. <link rel="prev" title="Tutorial: Creating a click counter using carrot and celery" href="tutorials/clickcounter.html" />
  23. </head>
  24. <body>
  25. <div class="related">
  26. <h3>Navigation</h3>
  27. <ul>
  28. <li class="right" style="margin-right: 10px">
  29. <a href="genindex.html" title="General Index"
  30. accesskey="I">index</a></li>
  31. <li class="right" >
  32. <a href="modindex.html" title="Global Module Index"
  33. accesskey="M">modules</a> |</li>
  34. <li class="right" >
  35. <a href="reference/index.html" title="Module API Reference"
  36. accesskey="N">next</a> |</li>
  37. <li class="right" >
  38. <a href="tutorials/clickcounter.html" title="Tutorial: Creating a click counter using carrot and celery"
  39. accesskey="P">previous</a> |</li>
  40. <li><a href="index.html">Celery v0.7.0 (unstable) documentation</a> &raquo;</li>
  41. </ul>
  42. </div>
  43. <div class="document">
  44. <div class="documentwrapper">
  45. <div class="bodywrapper">
  46. <div class="body">
  47. <div class="section" id="frequently-asked-questions">
  48. <h1>Frequently Asked Questions<a class="headerlink" href="#frequently-asked-questions" title="Permalink to this headline">¶</a></h1>
  49. <div class="section" id="questions">
  50. <h2>Questions<a class="headerlink" href="#questions" title="Permalink to this headline">¶</a></h2>
  51. <div class="section" id="mysql-is-throwing-deadlock-errors-what-can-i-do">
  52. <h3>MySQL is throwing deadlock errors, what can I do?<a class="headerlink" href="#mysql-is-throwing-deadlock-errors-what-can-i-do" title="Permalink to this headline">¶</a></h3>
  53. <p><strong>Answer:</strong> MySQL has default isolation level set to <tt class="docutils literal"><span class="pre">REPEATABLE-READ</span></tt>,
  54. if you don&#8217;t really need that, set it to <tt class="docutils literal"><span class="pre">READ-COMMITTED</span></tt>.
  55. You can do that by adding the following to your <tt class="docutils literal"><span class="pre">my.cnf</span></tt>:</p>
  56. <div class="highlight-python"><div class="highlight"><pre><span class="p">[</span><span class="n">mysqld</span><span class="p">]</span>
  57. <span class="n">transaction</span><span class="o">-</span><span class="n">isolation</span> <span class="o">=</span> <span class="n">READ</span><span class="o">-</span><span class="n">COMMITTED</span>
  58. </pre></div>
  59. </div>
  60. <p>For more information about InnoDBs transaction model see <a class="reference external" href="http://dev.mysql.com/doc/refman/5.1/en/innodb-transaction-model.html">MySQL - The InnoDB
  61. Transaction Model and Locking</a> in the MySQL user manual.</p>
  62. <p>(Thanks to Honza Kral and Anton Tsigularov for this solution)</p>
  63. </div>
  64. <div class="section" id="celeryd-is-not-doing-anything-just-hanging">
  65. <h3>celeryd is not doing anything, just hanging<a class="headerlink" href="#celeryd-is-not-doing-anything-just-hanging" title="Permalink to this headline">¶</a></h3>
  66. <dl class="docutils">
  67. <dt><strong>Answer:</strong> See <a class="reference internal" href="#mysql-is-throwing-deadlock-errors-what-can-i-do">MySQL is throwing deadlock errors, what can I do?</a>.</dt>
  68. <dd>or <cite>Why is Task.delay/apply* just hanging?</cite>.</dd>
  69. </dl>
  70. </div>
  71. <div class="section" id="why-is-task-delay-apply-just-hanging">
  72. <h3>Why is Task.delay/apply* just hanging?`<a class="headerlink" href="#why-is-task-delay-apply-just-hanging" title="Permalink to this headline">¶</a></h3>
  73. <p><strong>Answer:</strong> <tt class="xref docutils literal"><span class="pre">amqplib</span></tt> hangs if it isn&#8217;t able to authenticate to the
  74. AMQP server, so make sure you are able to access the configured vhost using
  75. the user and password.</p>
  76. </div>
  77. <div class="section" id="why-won-t-celeryd-run-on-freebsd">
  78. <h3>Why won&#8217;t celeryd run on FreeBSD?<a class="headerlink" href="#why-won-t-celeryd-run-on-freebsd" title="Permalink to this headline">¶</a></h3>
  79. <p><strong>Answer:</strong> multiprocessing.Pool requires a working POSIX semaphore
  80. implementation which isn&#8217;t enabled in FreeBSD by default. You have to enable
  81. POSIX semaphores in the kernel and manually recompile multiprocessing.</p>
  82. </div>
  83. <div class="section" id="i-m-having-integrityerror-duplicate-key-errors-why">
  84. <h3>I&#8217;m having <tt class="docutils literal"><span class="pre">IntegrityError:</span> <span class="pre">Duplicate</span> <span class="pre">Key</span></tt> errors. Why?<a class="headerlink" href="#i-m-having-integrityerror-duplicate-key-errors-why" title="Permalink to this headline">¶</a></h3>
  85. <p><strong>Answer:</strong> See <a class="reference internal" href="#mysql-is-throwing-deadlock-errors-what-can-i-do">MySQL is throwing deadlock errors, what can I do?</a>.
  86. Thanks to howsthedotcom.</p>
  87. </div>
  88. <div class="section" id="why-won-t-my-task-run">
  89. <h3>Why won&#8217;t my Task run?<a class="headerlink" href="#why-won-t-my-task-run" title="Permalink to this headline">¶</a></h3>
  90. <p><strong>Answer:</strong> Did you register the task in the applications <tt class="docutils literal"><span class="pre">tasks.py</span></tt> module?
  91. (or in some other module Django loads by default, like <tt class="docutils literal"><span class="pre">models.py</span></tt>?).
  92. Also there might be syntax errors preventing the tasks module being imported.</p>
  93. <p>You can find out if the celery daemon is able to run the task by executing the
  94. task manually:</p>
  95. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">myapp.tasks</span> <span class="kn">import</span> <span class="n">MyPeriodicTask</span>
  96. <span class="gp">&gt;&gt;&gt; </span><span class="n">MyPeriodicTask</span><span class="o">.</span><span class="n">delay</span><span class="p">()</span>
  97. </pre></div>
  98. </div>
  99. <p>Watch celery daemons logfile (or output if not running as a daemon), to see
  100. if it&#8217;s able to find the task, or if some other error is happening.</p>
  101. </div>
  102. <div class="section" id="why-won-t-my-periodic-task-run">
  103. <h3>Why won&#8217;t my Periodic Task run?<a class="headerlink" href="#why-won-t-my-periodic-task-run" title="Permalink to this headline">¶</a></h3>
  104. <p><strong>Answer:</strong> See <a class="reference internal" href="#why-won-t-my-task-run">Why won&#8217;t my Task run?</a>.</p>
  105. </div>
  106. <div class="section" id="how-do-i-discard-all-waiting-tasks">
  107. <h3>How do I discard all waiting tasks?<a class="headerlink" href="#how-do-i-discard-all-waiting-tasks" title="Permalink to this headline">¶</a></h3>
  108. <p><strong>Answer:</strong> Use <tt class="docutils literal"><span class="pre">celery.task.discard_all()</span></tt>, like this:</p>
  109. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">celery.task</span> <span class="kn">import</span> <span class="n">discard_all</span>
  110. <span class="gp">&gt;&gt;&gt; </span><span class="n">discard_all</span><span class="p">()</span>
  111. <span class="go">1753</span>
  112. </pre></div>
  113. </div>
  114. <p>The number <tt class="docutils literal"><span class="pre">1753</span></tt> is the number of messages deleted.</p>
  115. <p>You can also start celeryd with the <tt class="docutils literal"><span class="pre">--discard</span></tt> argument which will
  116. accomplish the same thing.</p>
  117. </div>
  118. <div class="section" id="i-ve-discarded-messages-but-there-are-still-messages-left-in-the-queue">
  119. <h3>I&#8217;ve discarded messages, but there are still messages left in the queue?<a class="headerlink" href="#i-ve-discarded-messages-but-there-are-still-messages-left-in-the-queue" title="Permalink to this headline">¶</a></h3>
  120. <p><strong>Answer:</strong> Tasks are acknowledged (removed from the queue) as soon
  121. as they are actually executed. After the worker has received a task, it will
  122. take some time until it is actually executed, especially if there are a lot
  123. of tasks already waiting for execution. Messages that are not acknowledged are
  124. hold on to by the worker until it closes the connection to the broker (AMQP
  125. server). When that connection is closed (e.g because the worker was stopped)
  126. the tasks will be re-sent by the broker to the next available worker (or the
  127. same worker when it has been restarted), so to properly purge the queue of
  128. waiting tasks you have to stop all the workers, and then discard the tasks
  129. using <tt class="docutils literal"><span class="pre">discard_all</span></tt>.</p>
  130. </div>
  131. <div class="section" id="can-i-use-celery-with-activemq-stomp">
  132. <h3>Can I use celery with ActiveMQ/STOMP?<a class="headerlink" href="#can-i-use-celery-with-activemq-stomp" title="Permalink to this headline">¶</a></h3>
  133. <p><strong>Answer</strong>: Yes. But this is somewhat experimental for now.
  134. It is certainly working ok for me in a test configuration, but it has not
  135. been tested in production like RabbitMQ. If you have any problems with
  136. using STOMP and celery, please report the bugs to the issue tracker:</p>
  137. <blockquote>
  138. <a class="reference external" href="http://github.com/ask/celery/issues/">http://github.com/ask/celery/issues/</a></blockquote>
  139. <p>First you have to use the <tt class="docutils literal"><span class="pre">master</span></tt> branch of <tt class="docutils literal"><span class="pre">celery</span></tt>:</p>
  140. <div class="highlight-python"><pre>$ git clone git://github.com/ask/celery.git
  141. $ cd celery
  142. $ sudo python setup.py install
  143. $ cd ..</pre>
  144. </div>
  145. <p>Then you need to install the <tt class="docutils literal"><span class="pre">stompbackend</span></tt> branch of <tt class="docutils literal"><span class="pre">carrot</span></tt>:</p>
  146. <div class="highlight-python"><pre>$ git clone git://github.com/ask/carrot.git
  147. $ cd carrot
  148. $ git checkout stompbackend
  149. $ sudo python setup.py install
  150. $ cd ..</pre>
  151. </div>
  152. <p>And my fork of <tt class="docutils literal"><span class="pre">python-stomp</span></tt> which adds non-blocking support:</p>
  153. <div class="highlight-python"><pre>$ hg clone http://bitbucket.org/asksol/python-stomp/
  154. $ cd python-stomp
  155. $ sudo python setup.py install
  156. $ cd ..</pre>
  157. </div>
  158. <p>In this example we will use a queue called <tt class="docutils literal"><span class="pre">celery</span></tt> which we created in
  159. the ActiveMQ web admin interface.</p>
  160. <p><strong>Note</strong>: For ActiveMQ the queue name has to have <tt class="docutils literal"><span class="pre">&quot;/queue/&quot;</span></tt> prepended to
  161. it. i.e. the queue <tt class="docutils literal"><span class="pre">celery</span></tt> becomes <tt class="docutils literal"><span class="pre">/queue/celery</span></tt>.</p>
  162. <p>Since a STOMP queue is a single named entity and it doesn&#8217;t have the
  163. routing capabilities of AMQP you need to set both the <tt class="docutils literal"><span class="pre">queue</span></tt>, and
  164. <tt class="docutils literal"><span class="pre">exchange</span></tt> settings to your queue name. This is a minor inconvenience since
  165. carrot needs to maintain the same interface for both AMQP and STOMP (obviously
  166. the one with the most capabilities won).</p>
  167. <p>Use the following specific settings in your <tt class="docutils literal"><span class="pre">settings.py</span></tt>:</p>
  168. <div class="highlight-python"><div class="highlight"><pre><span class="c"># Makes python-stomp the default backend for carrot.</span>
  169. <span class="n">CARROT_BACKEND</span> <span class="o">=</span> <span class="s">&quot;stomp&quot;</span>
  170. <span class="c"># STOMP hostname and port settings.</span>
  171. <span class="n">AMQP_HOST</span> <span class="o">=</span> <span class="s">&quot;localhost&quot;</span>
  172. <span class="n">AMQP_PORT</span> <span class="o">=</span> <span class="mf">61613</span>
  173. <span class="c"># The queue name to use (both queue and exchange must be set to the</span>
  174. <span class="c"># same queue name when using STOMP)</span>
  175. <span class="n">CELERY_AMQP_CONSUMER_QUEUE</span> <span class="o">=</span> <span class="s">&quot;/queue/celery&quot;</span>
  176. <span class="n">CELERY_AMQP_EXCHANGE</span> <span class="o">=</span> <span class="s">&quot;/queue/celery&quot;</span>
  177. </pre></div>
  178. </div>
  179. <p>Now you can go on reading the tutorial in the README, ignoring any AMQP
  180. specific options.</p>
  181. </div>
  182. <div class="section" id="which-features-are-not-supported-when-using-stomp">
  183. <h3>Which features are not supported when using STOMP?<a class="headerlink" href="#which-features-are-not-supported-when-using-stomp" title="Permalink to this headline">¶</a></h3>
  184. <p>This is a (possible incomplete) list of features not available when
  185. using the STOMP backend:</p>
  186. <ul class="simple">
  187. <li>routing keys</li>
  188. <li>exchange types (direct, topic, headers, etc)</li>
  189. <li>immediate</li>
  190. <li>mandatory</li>
  191. </ul>
  192. </div>
  193. <div class="section" id="can-i-send-some-tasks-to-only-some-servers">
  194. <h3>Can I send some tasks to only some servers?<a class="headerlink" href="#can-i-send-some-tasks-to-only-some-servers" title="Permalink to this headline">¶</a></h3>
  195. <p><strong>Answer:</strong> As of now there is only one use-case that works like this,
  196. and that is tasks of type <tt class="docutils literal"><span class="pre">A</span></tt> can be sent to servers <tt class="docutils literal"><span class="pre">x</span></tt> and <tt class="docutils literal"><span class="pre">y</span></tt>,
  197. while tasks of type <tt class="docutils literal"><span class="pre">B</span></tt> can be sent to server <tt class="docutils literal"><span class="pre">z</span></tt>. One server can&#8217;t
  198. handle more than one routing_key, but this is coming in a later release.</p>
  199. <p>Say you have two servers, <tt class="docutils literal"><span class="pre">x</span></tt>, and <tt class="docutils literal"><span class="pre">y</span></tt> that handles regular tasks,
  200. and one server <tt class="docutils literal"><span class="pre">z</span></tt>, that only handles feed related tasks, you can use this
  201. configuration:</p>
  202. <blockquote>
  203. <ul class="simple">
  204. <li>Servers <tt class="docutils literal"><span class="pre">x</span></tt> and <tt class="docutils literal"><span class="pre">y</span></tt>: settings.py:</li>
  205. </ul>
  206. <div class="highlight-python"><div class="highlight"><pre><span class="n">AMQP_SERVER</span> <span class="o">=</span> <span class="s">&quot;rabbit&quot;</span>
  207. <span class="n">AMQP_PORT</span> <span class="o">=</span> <span class="mf">5678</span>
  208. <span class="n">AMQP_USER</span> <span class="o">=</span> <span class="s">&quot;myapp&quot;</span>
  209. <span class="n">AMQP_PASSWORD</span> <span class="o">=</span> <span class="s">&quot;secret&quot;</span>
  210. <span class="n">AMQP_VHOST</span> <span class="o">=</span> <span class="s">&quot;myapp&quot;</span>
  211. <span class="n">CELERY_AMQP_CONSUMER_QUEUE</span> <span class="o">=</span> <span class="s">&quot;regular_tasks&quot;</span>
  212. <span class="n">CELERY_AMQP_EXCHANGE</span> <span class="o">=</span> <span class="s">&quot;tasks&quot;</span>
  213. <span class="n">CELERY_AMQP_PUBLISHER_ROUTING_KEY</span> <span class="o">=</span> <span class="s">&quot;task.regular&quot;</span>
  214. <span class="n">CELERY_AMQP_CONSUMER_ROUTING_KEY</span> <span class="o">=</span> <span class="s">&quot;task.#&quot;</span>
  215. <span class="n">CELERY_AMQP_EXCHANGE_TYPE</span> <span class="o">=</span> <span class="s">&quot;topic&quot;</span>
  216. </pre></div>
  217. </div>
  218. <ul class="simple">
  219. <li>Server <tt class="docutils literal"><span class="pre">z</span></tt>: settings.py:</li>
  220. </ul>
  221. <div class="highlight-python"><div class="highlight"><pre><span class="n">AMQP_SERVER</span> <span class="o">=</span> <span class="s">&quot;rabbit&quot;</span>
  222. <span class="n">AMQP_PORT</span> <span class="o">=</span> <span class="mf">5678</span>
  223. <span class="n">AMQP_USER</span> <span class="o">=</span> <span class="s">&quot;myapp&quot;</span>
  224. <span class="n">AMQP_PASSWORD</span> <span class="o">=</span> <span class="s">&quot;secret&quot;</span>
  225. <span class="n">AMQP_VHOST</span> <span class="o">=</span> <span class="s">&quot;myapp&quot;</span>
  226. <span class="n">CELERY_AMQP_EXCHANGE</span> <span class="o">=</span> <span class="s">&quot;tasks&quot;</span>
  227. <span class="n">CELERY_AMQP_PUBLISHER_ROUTING_KEY</span> <span class="o">=</span> <span class="s">&quot;task.regular&quot;</span>
  228. <span class="n">CELERY_AMQP_EXCHANGE_TYPE</span> <span class="o">=</span> <span class="s">&quot;topic&quot;</span>
  229. <span class="c"># This is the settings different for this server:</span>
  230. <span class="n">CELERY_AMQP_CONSUMER_QUEUE</span> <span class="o">=</span> <span class="s">&quot;feed_tasks&quot;</span>
  231. <span class="n">CELERY_AMQP_CONSUMER_ROUTING_KEY</span> <span class="o">=</span> <span class="s">&quot;feed.#&quot;</span>
  232. </pre></div>
  233. </div>
  234. </blockquote>
  235. <p>Now to make a Task run on the <tt class="docutils literal"><span class="pre">z</span></tt> server you need to set its
  236. <tt class="docutils literal"><span class="pre">routing_key</span></tt> attribute so it starts with the words <tt class="docutils literal"><span class="pre">&quot;task.feed.&quot;</span></tt>:</p>
  237. <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">feedaggregator.models</span> <span class="kn">import</span> <span class="n">Feed</span>
  238. <span class="kn">from</span> <span class="nn">celery.task</span> <span class="kn">import</span> <span class="n">Task</span>
  239. <span class="k">class</span> <span class="nc">FeedImportTask</span><span class="p">(</span><span class="n">Task</span><span class="p">):</span>
  240. <span class="n">routing_key</span> <span class="o">=</span> <span class="s">&quot;feed.importer&quot;</span>
  241. <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">feed_url</span><span class="p">):</span>
  242. <span class="c"># something importing the feed</span>
  243. <span class="n">Feed</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">import_feed</span><span class="p">(</span><span class="n">feed_url</span><span class="p">)</span>
  244. </pre></div>
  245. </div>
  246. <p>You can also override this using the <tt class="docutils literal"><span class="pre">routing_key</span></tt> argument to
  247. <tt class="xref docutils literal"><span class="pre">celery.task.apply_async()</span></tt>:</p>
  248. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">celery.task</span> <span class="kn">import</span> <span class="n">apply_async</span>
  249. <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">myapp.tasks</span> <span class="kn">import</span> <span class="n">RefreshFeedTask</span>
  250. <span class="gp">&gt;&gt;&gt; </span><span class="n">apply_async</span><span class="p">(</span><span class="n">RefreshFeedTask</span><span class="p">,</span> <span class="n">args</span><span class="o">=</span><span class="p">[</span><span class="s">&quot;http://cnn.com/rss&quot;</span><span class="p">],</span>
  251. <span class="gp">... </span> <span class="n">routing_key</span><span class="o">=</span><span class="s">&quot;feed.importer&quot;</span><span class="p">)</span>
  252. </pre></div>
  253. </div>
  254. </div>
  255. <div class="section" id="can-i-use-celery-without-django">
  256. <h3>Can I use celery without Django?<a class="headerlink" href="#can-i-use-celery-without-django" title="Permalink to this headline">¶</a></h3>
  257. <p><strong>Answer:</strong> Yes.</p>
  258. <p>Celery uses something called loaders to read/setup configuration, import
  259. modules that registers tasks and to decide what happens when a task is
  260. executed. Currently there are two loaders, the default loader and the Django
  261. loader. If you want to use celery without a Django project, you either have to
  262. use the default loader, or a write a loader of your own.</p>
  263. <p>The rest of this answer describes how to use the default loader.</p>
  264. <p>You need a configuration file named <tt class="docutils literal"><span class="pre">celeryconfig.py</span></tt>, either in the
  265. directory you run <tt class="docutils literal"><span class="pre">celeryd</span></tt> in, or in a Python library path where it is
  266. able to find it. The configuration file can contain any of the settings
  267. described in <a title="" class="reference external" href="reference/celery.conf.html#module-celery.conf"><tt class="xref docutils literal"><span class="pre">celery.conf</span></tt></a>, and in additional if you&#8217;re using the
  268. database backend you have to configure the database. Here is an example
  269. configuration using the database backend with MySQL:</p>
  270. <div class="highlight-python"><div class="highlight"><pre><span class="c"># Broker configuration</span>
  271. <span class="n">AMQP_SERVER</span> <span class="o">=</span> <span class="s">&quot;localhost&quot;</span>
  272. <span class="n">AMQP_PORT</span> <span class="o">=</span> <span class="s">&quot;5672&quot;</span>
  273. <span class="n">AMQP_VHOST</span> <span class="o">=</span> <span class="s">&quot;celery&quot;</span>
  274. <span class="n">AMQP_USER</span> <span class="o">=</span> <span class="s">&quot;celery&quot;</span>
  275. <span class="n">AMQP_PASSWORD</span> <span class="o">=</span> <span class="s">&quot;celerysecret&quot;</span>
  276. <span class="n">CARROT_BACKEND</span><span class="o">=</span><span class="s">&quot;amqp&quot;</span>
  277. <span class="c"># Using the database backend.</span>
  278. <span class="n">CELERY_BACKEND</span> <span class="o">=</span> <span class="s">&quot;database&quot;</span>
  279. <span class="c"># Number of processes that processes tasks simultaneously.</span>
  280. <span class="n">CELERYD_CONCURRENCY</span> <span class="o">=</span> <span class="mf">8</span>
  281. <span class="c"># Modules to import when celeryd starts.</span>
  282. <span class="c"># This must import every module where you register tasks so celeryd</span>
  283. <span class="c"># is able to find and run them.</span>
  284. <span class="n">CELERY_IMPORTS</span> <span class="o">=</span> <span class="p">(</span><span class="s">&quot;mytaskmodule1&quot;</span><span class="p">,</span> <span class="s">&quot;mytaskmodule2&quot;</span><span class="p">)</span>
  285. </pre></div>
  286. </div>
  287. <p>Now with this configuration file in the current directory you have to
  288. run <tt class="docutils literal"><span class="pre">celeryinit</span></tt> to create the database tables:</p>
  289. <div class="highlight-python"><pre>$ celeryinit</pre>
  290. </div>
  291. <p>Then you should be able to successfully run <tt class="docutils literal"><span class="pre">celeryd</span></tt>:</p>
  292. <div class="highlight-python"><pre>$ celeryd --loglevel=INFO</pre>
  293. </div>
  294. <p>and send a task from a python shell (note that it must be able to import
  295. <tt class="docutils literal"><span class="pre">celeryconfig.py</span></tt>):</p>
  296. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">celery.task.builtins</span> <span class="kn">import</span> <span class="n">PingTask</span>
  297. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span> <span class="o">=</span> <span class="n">PingTask</span><span class="o">.</span><span class="n">apply_async</span><span class="p">()</span>
  298. <span class="gp">&gt;&gt;&gt; </span><span class="n">result</span><span class="o">.</span><span class="n">get</span><span class="p">()</span>
  299. <span class="go">&#39;pong&#39;</span>
  300. </pre></div>
  301. </div>
  302. </div>
  303. </div>
  304. </div>
  305. </div>
  306. </div>
  307. </div>
  308. <div class="sphinxsidebar">
  309. <div class="sphinxsidebarwrapper">
  310. <h3><a href="index.html">Table Of Contents</a></h3>
  311. <ul>
  312. <li><a class="reference external" href="">Frequently Asked Questions</a><ul>
  313. <li><a class="reference external" href="#questions">Questions</a><ul>
  314. <li><a class="reference external" href="#mysql-is-throwing-deadlock-errors-what-can-i-do">MySQL is throwing deadlock errors, what can I do?</a></li>
  315. <li><a class="reference external" href="#celeryd-is-not-doing-anything-just-hanging">celeryd is not doing anything, just hanging</a></li>
  316. <li><a class="reference external" href="#why-is-task-delay-apply-just-hanging">Why is Task.delay/apply* just hanging?`</a></li>
  317. <li><a class="reference external" href="#why-won-t-celeryd-run-on-freebsd">Why won&#8217;t celeryd run on FreeBSD?</a></li>
  318. <li><a class="reference external" href="#i-m-having-integrityerror-duplicate-key-errors-why">I&#8217;m having <tt class="docutils literal"><span class="pre">IntegrityError:</span> <span class="pre">Duplicate</span> <span class="pre">Key</span></tt> errors. Why?</a></li>
  319. <li><a class="reference external" href="#why-won-t-my-task-run">Why won&#8217;t my Task run?</a></li>
  320. <li><a class="reference external" href="#why-won-t-my-periodic-task-run">Why won&#8217;t my Periodic Task run?</a></li>
  321. <li><a class="reference external" href="#how-do-i-discard-all-waiting-tasks">How do I discard all waiting tasks?</a></li>
  322. <li><a class="reference external" href="#i-ve-discarded-messages-but-there-are-still-messages-left-in-the-queue">I&#8217;ve discarded messages, but there are still messages left in the queue?</a></li>
  323. <li><a class="reference external" href="#can-i-use-celery-with-activemq-stomp">Can I use celery with ActiveMQ/STOMP?</a></li>
  324. <li><a class="reference external" href="#which-features-are-not-supported-when-using-stomp">Which features are not supported when using STOMP?</a></li>
  325. <li><a class="reference external" href="#can-i-send-some-tasks-to-only-some-servers">Can I send some tasks to only some servers?</a></li>
  326. <li><a class="reference external" href="#can-i-use-celery-without-django">Can I use celery without Django?</a></li>
  327. </ul>
  328. </li>
  329. </ul>
  330. </li>
  331. </ul>
  332. <h4>Previous topic</h4>
  333. <p class="topless"><a href="tutorials/clickcounter.html"
  334. title="previous chapter">Tutorial: Creating a click counter using carrot and celery</a></p>
  335. <h4>Next topic</h4>
  336. <p class="topless"><a href="reference/index.html"
  337. title="next chapter">Module API Reference</a></p>
  338. <h3>This Page</h3>
  339. <ul class="this-page-menu">
  340. <li><a href="sources/faq.txt"
  341. rel="nofollow">Show Source</a></li>
  342. </ul>
  343. <div id="searchbox" style="display: none">
  344. <h3>Quick search</h3>
  345. <form class="search" action="search.html" method="get">
  346. <input type="text" name="q" size="18" />
  347. <input type="submit" value="Go" />
  348. <input type="hidden" name="check_keywords" value="yes" />
  349. <input type="hidden" name="area" value="default" />
  350. </form>
  351. <p class="searchtip" style="font-size: 90%">
  352. Enter search terms or a module, class or function name.
  353. </p>
  354. </div>
  355. <script type="text/javascript">$('#searchbox').show(0);</script>
  356. </div>
  357. </div>
  358. <div class="clearer"></div>
  359. </div>
  360. <div class="related">
  361. <h3>Navigation</h3>
  362. <ul>
  363. <li class="right" style="margin-right: 10px">
  364. <a href="genindex.html" title="General Index"
  365. >index</a></li>
  366. <li class="right" >
  367. <a href="modindex.html" title="Global Module Index"
  368. >modules</a> |</li>
  369. <li class="right" >
  370. <a href="reference/index.html" title="Module API Reference"
  371. >next</a> |</li>
  372. <li class="right" >
  373. <a href="tutorials/clickcounter.html" title="Tutorial: Creating a click counter using carrot and celery"
  374. >previous</a> |</li>
  375. <li><a href="index.html">Celery v0.7.0 (unstable) documentation</a> &raquo;</li>
  376. </ul>
  377. </div>
  378. <div class="footer">
  379. &copy; Copyright 2009, Ask Solem.
  380. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.2.
  381. </div>
  382. </body>
  383. </html>