123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
- <title>Frequently Asked Questions — Celery v0.7.0 (unstable) documentation</title>
- <link rel="stylesheet" href="static/nature.css" type="text/css" />
- <link rel="stylesheet" href="static/pygments.css" type="text/css" />
- <script type="text/javascript">
- var DOCUMENTATION_OPTIONS = {
- URL_ROOT: '',
- VERSION: '0.7.0 (unstable)',
- COLLAPSE_MODINDEX: false,
- FILE_SUFFIX: '.html',
- HAS_SOURCE: true
- };
- </script>
- <script type="text/javascript" src="static/jquery.js"></script>
- <script type="text/javascript" src="static/doctools.js"></script>
- <link rel="top" title="Celery v0.7.0 (unstable) documentation" href="index.html" />
- <link rel="next" title="Module API Reference" href="reference/index.html" />
- <link rel="prev" title="Tutorial: Creating a click counter using carrot and celery" href="tutorials/clickcounter.html" />
- </head>
- <body>
- <div class="related">
- <h3>Navigation</h3>
- <ul>
- <li class="right" style="margin-right: 10px">
- <a href="genindex.html" title="General Index"
- accesskey="I">index</a></li>
- <li class="right" >
- <a href="modindex.html" title="Global Module Index"
- accesskey="M">modules</a> |</li>
- <li class="right" >
- <a href="reference/index.html" title="Module API Reference"
- accesskey="N">next</a> |</li>
- <li class="right" >
- <a href="tutorials/clickcounter.html" title="Tutorial: Creating a click counter using carrot and celery"
- accesskey="P">previous</a> |</li>
- <li><a href="index.html">Celery v0.7.0 (unstable) documentation</a> »</li>
- </ul>
- </div>
- <div class="document">
- <div class="documentwrapper">
- <div class="bodywrapper">
- <div class="body">
-
- <div class="section" id="frequently-asked-questions">
- <h1>Frequently Asked Questions<a class="headerlink" href="#frequently-asked-questions" title="Permalink to this headline">¶</a></h1>
- <div class="section" id="mysql-is-throwing-deadlock-errors-what-can-i-do">
- <h2>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></h2>
- <p><strong>Answer:</strong> MySQL has default isolation level set to <tt class="docutils literal"><span class="pre">REPEATABLE-READ</span></tt>,
- if you don’t really need that, set it to <tt class="docutils literal"><span class="pre">READ-COMMITTED</span></tt>.
- You can do that by adding the following to your <tt class="docutils literal"><span class="pre">my.cnf</span></tt>:</p>
- <div class="highlight-python"><div class="highlight"><pre><span class="p">[</span><span class="n">mysqld</span><span class="p">]</span>
- <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>
- </pre></div>
- </div>
- <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
- Transaction Model and Locking</a> in the MySQL user manual.</p>
- <p>(Thanks to Honza Kral and Anton Tsigularov for this solution)</p>
- </div>
- <div class="section" id="celeryd-is-not-doing-anything-just-hanging">
- <h2>celeryd is not doing anything, just hanging<a class="headerlink" href="#celeryd-is-not-doing-anything-just-hanging" title="Permalink to this headline">¶</a></h2>
- <dl class="docutils">
- <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>
- <dd>or <cite>Why is Task.delay/apply* just hanging?</cite>.</dd>
- </dl>
- </div>
- <div class="section" id="why-is-task-delay-apply-just-hanging">
- <h2>Why is Task.delay/apply* just hanging?`<a class="headerlink" href="#why-is-task-delay-apply-just-hanging" title="Permalink to this headline">¶</a></h2>
- <p><strong>Answer:</strong> <tt class="xref docutils literal"><span class="pre">amqplib</span></tt> hangs if it isn’t able to authenticate to the
- AMQP server, so make sure you are able to access the configured vhost using
- the user and password.</p>
- </div>
- <div class="section" id="why-won-t-celeryd-run-on-freebsd">
- <h2>Why won’t celeryd run on FreeBSD?<a class="headerlink" href="#why-won-t-celeryd-run-on-freebsd" title="Permalink to this headline">¶</a></h2>
- <p><strong>Answer:</strong> multiprocessing.Pool requires a working POSIX semaphore
- implementation which isn’t enabled in FreeBSD by default. You have to enable
- POSIX semaphores in the kernel and manually recompile multiprocessing.</p>
- </div>
- <div class="section" id="i-m-having-integrityerror-duplicate-key-errors-why">
- <h2>I’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></h2>
- <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>.
- Thanks to howsthedotcom.</p>
- </div>
- <div class="section" id="why-won-t-my-task-run">
- <h2>Why won’t my Task run?<a class="headerlink" href="#why-won-t-my-task-run" title="Permalink to this headline">¶</a></h2>
- <p><strong>Answer:</strong> Did you register the task in the applications <tt class="docutils literal"><span class="pre">tasks.py</span></tt> module?
- (or in some other module Django loads by default, like <tt class="docutils literal"><span class="pre">models.py</span></tt>?).
- Also there might be syntax errors preventing the tasks module being imported.</p>
- <p>You can find out if the celery daemon is able to run the task by executing the
- task manually:</p>
- <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">myapp.tasks</span> <span class="kn">import</span> <span class="n">MyPeriodicTask</span>
- <span class="gp">>>> </span><span class="n">MyPeriodicTask</span><span class="o">.</span><span class="n">delay</span><span class="p">()</span>
- </pre></div>
- </div>
- <p>Watch celery daemons logfile (or output if not running as a daemon), to see
- if it’s able to find the task, or if some other error is happening.</p>
- </div>
- <div class="section" id="why-won-t-my-periodic-task-run">
- <h2>Why won’t my Periodic Task run?<a class="headerlink" href="#why-won-t-my-periodic-task-run" title="Permalink to this headline">¶</a></h2>
- <p><strong>Answer:</strong> See <a class="reference internal" href="#why-won-t-my-task-run">Why won’t my Task run?</a>.</p>
- </div>
- <div class="section" id="how-do-i-discard-all-waiting-tasks">
- <h2>How do I discard all waiting tasks?<a class="headerlink" href="#how-do-i-discard-all-waiting-tasks" title="Permalink to this headline">¶</a></h2>
- <p><strong>Answer:</strong> Use <tt class="docutils literal"><span class="pre">celery.task.discard_all()</span></tt>, like this:</p>
- <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">celery.task</span> <span class="kn">import</span> <span class="n">discard_all</span>
- <span class="gp">>>> </span><span class="n">discard_all</span><span class="p">()</span>
- <span class="go">1753</span>
- </pre></div>
- </div>
- <p>The number <tt class="docutils literal"><span class="pre">1753</span></tt> is the number of messages deleted.</p>
- <p>You can also start celeryd with the <tt class="docutils literal"><span class="pre">--discard</span></tt> argument which will
- accomplish the same thing.</p>
- </div>
- <div class="section" id="i-ve-discarded-messages-but-there-are-still-messages-left-in-the-queue">
- <h2>I’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></h2>
- <p><strong>Answer:</strong> Tasks are acknowledged (removed from the queue) as soon
- as they are actually executed. After the worker has received a task, it will
- take some time until it is actually executed, especially if there are a lot
- of tasks already waiting for execution. Messages that are not acknowledged are
- hold on to by the worker until it closes the connection to the broker (AMQP
- server). When that connection is closed (e.g because the worker was stopped)
- the tasks will be re-sent by the broker to the next available worker (or the
- same worker when it has been restarted), so to properly purge the queue of
- waiting tasks you have to stop all the workers, and then discard the tasks
- using <tt class="docutils literal"><span class="pre">discard_all</span></tt>.</p>
- </div>
- <div class="section" id="can-i-use-celery-with-activemq-stomp">
- <h2>Can I use celery with ActiveMQ/STOMP?<a class="headerlink" href="#can-i-use-celery-with-activemq-stomp" title="Permalink to this headline">¶</a></h2>
- <p><strong>Answer</strong>: Yes. But this is somewhat experimental for now.
- It is certainly working ok for me in a test configuration, but it has not
- been tested in production like RabbitMQ. If you have any problems with
- using STOMP and celery, please report the bugs to the issue tracker:</p>
- <blockquote>
- <a class="reference external" href="http://github.com/ask/celery/issues/">http://github.com/ask/celery/issues/</a></blockquote>
- <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>
- <div class="highlight-python"><pre>$ git clone git://github.com/ask/celery.git
- $ cd celery
- $ sudo python setup.py install
- $ cd ..</pre>
- </div>
- <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>
- <div class="highlight-python"><pre>$ git clone git://github.com/ask/carrot.git
- $ cd carrot
- $ git checkout stompbackend
- $ sudo python setup.py install
- $ cd ..</pre>
- </div>
- <p>And my fork of <tt class="docutils literal"><span class="pre">python-stomp</span></tt> which adds non-blocking support:</p>
- <div class="highlight-python"><pre>$ hg clone http://bitbucket.org/asksol/python-stomp/
- $ cd python-stomp
- $ sudo python setup.py install
- $ cd ..</pre>
- </div>
- <p>In this example we will use a queue called <tt class="docutils literal"><span class="pre">celery</span></tt> which we created in
- the ActiveMQ web admin interface.</p>
- <p><strong>Note</strong>: For ActiveMQ the queue name has to have <tt class="docutils literal"><span class="pre">"/queue/"</span></tt> prepended to
- 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>
- <p>Since a STOMP queue is a single named entity and it doesn’t have the
- routing capabilities of AMQP you need to set both the <tt class="docutils literal"><span class="pre">queue</span></tt>, and
- <tt class="docutils literal"><span class="pre">exchange</span></tt> settings to your queue name. This is a minor inconvenience since
- carrot needs to maintain the same interface for both AMQP and STOMP (obviously
- the one with the most capabilities won).</p>
- <p>Use the following specific settings in your <tt class="docutils literal"><span class="pre">settings.py</span></tt>:</p>
- <div class="highlight-python"><div class="highlight"><pre><span class="c"># Makes python-stomp the default backend for carrot.</span>
- <span class="n">CARROT_BACKEND</span> <span class="o">=</span> <span class="s">"stomp"</span>
- <span class="c"># STOMP hostname and port settings.</span>
- <span class="n">AMQP_HOST</span> <span class="o">=</span> <span class="s">"localhost"</span>
- <span class="n">AMQP_PORT</span> <span class="o">=</span> <span class="mf">61613</span>
- <span class="c"># The queue name to use (both queue and exchange must be set to the</span>
- <span class="c"># same queue name when using STOMP)</span>
- <span class="n">CELERY_AMQP_CONSUMER_QUEUE</span> <span class="o">=</span> <span class="s">"/queue/celery"</span>
- <span class="n">CELERY_AMQP_EXCHANGE</span> <span class="o">=</span> <span class="s">"/queue/celery"</span>
- </pre></div>
- </div>
- <p>Now you can go on reading the tutorial in the README, ignoring any AMQP
- specific options.</p>
- </div>
- <div class="section" id="which-features-are-not-supported-when-using-stomp">
- <h2>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></h2>
- <p>This is a (possible incomplete) list of features not available when
- using the STOMP backend:</p>
- <ul class="simple">
- <li>routing keys</li>
- <li>exchange types (direct, topic, headers, etc)</li>
- <li>immediate</li>
- <li>mandatory</li>
- </ul>
- </div>
- <div class="section" id="can-i-send-some-tasks-to-only-some-servers">
- <h2>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></h2>
- <p><strong>Answer:</strong> As of now there is only one use-case that works like this,
- 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>,
- 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’t
- handle more than one routing_key, but this is coming in a later release.</p>
- <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,
- and one server <tt class="docutils literal"><span class="pre">z</span></tt>, that only handles feed related tasks, you can use this
- configuration:</p>
- <blockquote>
- <ul class="simple">
- <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>
- </ul>
- <div class="highlight-python"><div class="highlight"><pre><span class="n">AMQP_SERVER</span> <span class="o">=</span> <span class="s">"rabbit"</span>
- <span class="n">AMQP_PORT</span> <span class="o">=</span> <span class="mf">5678</span>
- <span class="n">AMQP_USER</span> <span class="o">=</span> <span class="s">"myapp"</span>
- <span class="n">AMQP_PASSWORD</span> <span class="o">=</span> <span class="s">"secret"</span>
- <span class="n">AMQP_VHOST</span> <span class="o">=</span> <span class="s">"myapp"</span>
- <span class="n">CELERY_AMQP_CONSUMER_QUEUE</span> <span class="o">=</span> <span class="s">"regular_tasks"</span>
- <span class="n">CELERY_AMQP_EXCHANGE</span> <span class="o">=</span> <span class="s">"tasks"</span>
- <span class="n">CELERY_AMQP_PUBLISHER_ROUTING_KEY</span> <span class="o">=</span> <span class="s">"task.regular"</span>
- <span class="n">CELERY_AMQP_CONSUMER_ROUTING_KEY</span> <span class="o">=</span> <span class="s">"task.#"</span>
- <span class="n">CELERY_AMQP_EXCHANGE_TYPE</span> <span class="o">=</span> <span class="s">"topic"</span>
- </pre></div>
- </div>
- <ul class="simple">
- <li>Server <tt class="docutils literal"><span class="pre">z</span></tt>: settings.py:</li>
- </ul>
- <div class="highlight-python"><div class="highlight"><pre><span class="n">AMQP_SERVER</span> <span class="o">=</span> <span class="s">"rabbit"</span>
- <span class="n">AMQP_PORT</span> <span class="o">=</span> <span class="mf">5678</span>
- <span class="n">AMQP_USER</span> <span class="o">=</span> <span class="s">"myapp"</span>
- <span class="n">AMQP_PASSWORD</span> <span class="o">=</span> <span class="s">"secret"</span>
- <span class="n">AMQP_VHOST</span> <span class="o">=</span> <span class="s">"myapp"</span>
- <span class="n">CELERY_AMQP_EXCHANGE</span> <span class="o">=</span> <span class="s">"tasks"</span>
- <span class="n">CELERY_AMQP_PUBLISHER_ROUTING_KEY</span> <span class="o">=</span> <span class="s">"task.regular"</span>
- <span class="n">CELERY_AMQP_EXCHANGE_TYPE</span> <span class="o">=</span> <span class="s">"topic"</span>
- <span class="c"># This is the settings different for this server:</span>
- <span class="n">CELERY_AMQP_CONSUMER_QUEUE</span> <span class="o">=</span> <span class="s">"feed_tasks"</span>
- <span class="n">CELERY_AMQP_CONSUMER_ROUTING_KEY</span> <span class="o">=</span> <span class="s">"feed.#"</span>
- </pre></div>
- </div>
- </blockquote>
- <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
- <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">"task.feed."</span></tt>:</p>
- <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>
- <span class="kn">from</span> <span class="nn">celery.task</span> <span class="kn">import</span> <span class="n">Task</span>
- <span class="k">class</span> <span class="nc">FeedImportTask</span><span class="p">(</span><span class="n">Task</span><span class="p">):</span>
- <span class="n">routing_key</span> <span class="o">=</span> <span class="s">"feed.importer"</span>
- <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>
- <span class="c"># something importing the feed</span>
- <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>
- </pre></div>
- </div>
- <p>You can also override this using the <tt class="docutils literal"><span class="pre">routing_key</span></tt> argument to
- <tt class="xref docutils literal"><span class="pre">celery.task.apply_async()</span></tt>:</p>
- <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">celery.task</span> <span class="kn">import</span> <span class="n">apply_async</span>
- <span class="gp">>>> </span><span class="kn">from</span> <span class="nn">myapp.tasks</span> <span class="kn">import</span> <span class="n">RefreshFeedTask</span>
- <span class="gp">>>> </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">"http://cnn.com/rss"</span><span class="p">],</span>
- <span class="gp">... </span> <span class="n">routing_key</span><span class="o">=</span><span class="s">"feed.importer"</span><span class="p">)</span>
- </pre></div>
- </div>
- </div>
- <div class="section" id="can-i-use-celery-without-django">
- <h2>Can I use celery without Django?<a class="headerlink" href="#can-i-use-celery-without-django" title="Permalink to this headline">¶</a></h2>
- <p><strong>Answer:</strong> Yes.</p>
- <p>Celery uses something called loaders to read/setup configuration, import
- modules that registers tasks and to decide what happens when a task is
- executed. Currently there are two loaders, the default loader and the Django
- loader. If you want to use celery without a Django project, you either have to
- use the default loader, or write a loader of your own.</p>
- <p>The rest of this answer describes how to use the default loader.</p>
- <p>First of all, installation. You need to get the development version of
- celery from github:</p>
- <div class="highlight-python"><pre>$ git clone git://github.com/ask/celery.git
- $ cd celery
- # python setup.py install # as root</pre>
- </div>
- <p>While it is possible to use celery from outside of Django, we still need
- Django itself to run, this is to use the ORM and cache-framework, etc.
- Duplicating these features would be time consuming and mostly pointless, so
- we decided that having a dependency on Django itself was a good thing.
- Install Django using your favorite install tool, <tt class="docutils literal"><span class="pre">easy_install</span></tt>, <tt class="docutils literal"><span class="pre">pip</span></tt>, or
- whatever:</p>
- <div class="highlight-python"><div class="highlight"><pre><span class="c"># easy_install django # as root</span>
- </pre></div>
- </div>
- <p>You need a configuration file named <tt class="docutils literal"><span class="pre">celeryconfig.py</span></tt>, either in the
- directory you run <tt class="docutils literal"><span class="pre">celeryd</span></tt> in, or in a Python library path where it is
- able to find it. The configuration file can contain any of the settings
- 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’re using the
- database backend you have to configure the database. Here is an example
- configuration using the database backend with MySQL:</p>
- <div class="highlight-python"><div class="highlight"><pre><span class="c"># Broker configuration</span>
- <span class="n">AMQP_SERVER</span> <span class="o">=</span> <span class="s">"localhost"</span>
- <span class="n">AMQP_PORT</span> <span class="o">=</span> <span class="s">"5672"</span>
- <span class="n">AMQP_VHOST</span> <span class="o">=</span> <span class="s">"celery"</span>
- <span class="n">AMQP_USER</span> <span class="o">=</span> <span class="s">"celery"</span>
- <span class="n">AMQP_PASSWORD</span> <span class="o">=</span> <span class="s">"celerysecret"</span>
- <span class="n">CARROT_BACKEND</span><span class="o">=</span><span class="s">"amqp"</span>
- <span class="c"># Using the database backend.</span>
- <span class="n">CELERY_BACKEND</span> <span class="o">=</span> <span class="s">"database"</span>
- <span class="n">DATABASE_ENGINE</span> <span class="o">=</span> <span class="s">"mysql"</span> <span class="c"># see Django docs for a description of these.</span>
- <span class="n">DATABASE_NAME</span> <span class="o">=</span> <span class="s">"mydb"</span>
- <span class="n">DATABASE_HOST</span> <span class="o">=</span> <span class="s">"mydb.example.org"</span>
- <span class="n">DATABASE_USER</span> <span class="o">=</span> <span class="s">"myuser"</span>
- <span class="n">DATABASE_PASSWORD</span> <span class="o">=</span> <span class="s">"mysecret"</span>
- <span class="c"># Number of processes that processes tasks simultaneously.</span>
- <span class="n">CELERYD_CONCURRENCY</span> <span class="o">=</span> <span class="mf">8</span>
- <span class="c"># Modules to import when celeryd starts.</span>
- <span class="c"># This must import every module where you register tasks so celeryd</span>
- <span class="c"># is able to find and run them.</span>
- <span class="n">CELERY_IMPORTS</span> <span class="o">=</span> <span class="p">(</span><span class="s">"mytaskmodule1"</span><span class="p">,</span> <span class="s">"mytaskmodule2"</span><span class="p">)</span>
- </pre></div>
- </div>
- <p>Now with this configuration file in the current directory you have to
- run <tt class="docutils literal"><span class="pre">celeryinit</span></tt> to create the database tables:</p>
- <div class="highlight-python"><pre>$ celeryinit</pre>
- </div>
- <p>Then you should be able to successfully run <tt class="docutils literal"><span class="pre">celeryd</span></tt>:</p>
- <div class="highlight-python"><pre>$ celeryd --loglevel=INFO</pre>
- </div>
- <p>and send a task from a python shell (note that it must be able to import
- <tt class="docutils literal"><span class="pre">celeryconfig.py</span></tt>):</p>
- <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">celery.task.builtins</span> <span class="kn">import</span> <span class="n">PingTask</span>
- <span class="gp">>>> </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>
- <span class="gp">>>> </span><span class="n">result</span><span class="o">.</span><span class="n">get</span><span class="p">()</span>
- <span class="go">'pong'</span>
- </pre></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="sphinxsidebar">
- <div class="sphinxsidebarwrapper">
- <h3><a href="index.html">Table Of Contents</a></h3>
- <ul>
- <li><a class="reference external" href="">Frequently Asked Questions</a><ul>
- <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>
- <li><a class="reference external" href="#celeryd-is-not-doing-anything-just-hanging">celeryd is not doing anything, just hanging</a></li>
- <li><a class="reference external" href="#why-is-task-delay-apply-just-hanging">Why is Task.delay/apply* just hanging?`</a></li>
- <li><a class="reference external" href="#why-won-t-celeryd-run-on-freebsd">Why won’t celeryd run on FreeBSD?</a></li>
- <li><a class="reference external" href="#i-m-having-integrityerror-duplicate-key-errors-why">I’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>
- <li><a class="reference external" href="#why-won-t-my-task-run">Why won’t my Task run?</a></li>
- <li><a class="reference external" href="#why-won-t-my-periodic-task-run">Why won’t my Periodic Task run?</a></li>
- <li><a class="reference external" href="#how-do-i-discard-all-waiting-tasks">How do I discard all waiting tasks?</a></li>
- <li><a class="reference external" href="#i-ve-discarded-messages-but-there-are-still-messages-left-in-the-queue">I’ve discarded messages, but there are still messages left in the queue?</a></li>
- <li><a class="reference external" href="#can-i-use-celery-with-activemq-stomp">Can I use celery with ActiveMQ/STOMP?</a></li>
- <li><a class="reference external" href="#which-features-are-not-supported-when-using-stomp">Which features are not supported when using STOMP?</a></li>
- <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>
- <li><a class="reference external" href="#can-i-use-celery-without-django">Can I use celery without Django?</a></li>
- </ul>
- </li>
- </ul>
- <h4>Previous topic</h4>
- <p class="topless"><a href="tutorials/clickcounter.html"
- title="previous chapter">Tutorial: Creating a click counter using carrot and celery</a></p>
- <h4>Next topic</h4>
- <p class="topless"><a href="reference/index.html"
- title="next chapter">Module API Reference</a></p>
- <h3>This Page</h3>
- <ul class="this-page-menu">
- <li><a href="sources/faq.txt"
- rel="nofollow">Show Source</a></li>
- </ul>
- <div id="searchbox" style="display: none">
- <h3>Quick search</h3>
- <form class="search" action="search.html" method="get">
- <input type="text" name="q" size="18" />
- <input type="submit" value="Go" />
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- <p class="searchtip" style="font-size: 90%">
- Enter search terms or a module, class or function name.
- </p>
- </div>
- <script type="text/javascript">$('#searchbox').show(0);</script>
- </div>
- </div>
- <div class="clearer"></div>
- </div>
- <div class="related">
- <h3>Navigation</h3>
- <ul>
- <li class="right" style="margin-right: 10px">
- <a href="genindex.html" title="General Index"
- >index</a></li>
- <li class="right" >
- <a href="modindex.html" title="Global Module Index"
- >modules</a> |</li>
- <li class="right" >
- <a href="reference/index.html" title="Module API Reference"
- >next</a> |</li>
- <li class="right" >
- <a href="tutorials/clickcounter.html" title="Tutorial: Creating a click counter using carrot and celery"
- >previous</a> |</li>
- <li><a href="index.html">Celery v0.7.0 (unstable) documentation</a> »</li>
- </ul>
- </div>
- <div class="footer">
- © Copyright 2009, Ask Solem.
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.2.
- </div>
- </body>
- </html>
|