Source

eggDiscover / documentation / build / djcelery.html



<!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>The Django Celery Module &mdash; EggDiscover 0.1 documentation</title>
    
    <link rel="stylesheet" href="_static/default.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.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="EggDiscover 0.1 documentation" href="index.html" />
    <link rel="up" title="External apps used in this project" href="externalapps.html" />
    <link rel="next" title="The Twitter Module" href="twitter.html" />
    <link rel="prev" title="The User Social Auth Module" href="social_auth.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="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="twitter.html" title="The Twitter Module"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="social_auth.html" title="The User Social Auth Module"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">EggDiscover 0.1 documentation</a> &raquo;</li>
          <li><a href="externalapps.html" accesskey="U">External apps used in this project</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="the-django-celery-module">
<h1>The Django Celery Module<a class="headerlink" href="#the-django-celery-module" title="Permalink to this headline"></a></h1>
<p>djcelery is an application to run tasks in the background.</p>
<span class="target" id="module-djcelery"></span><p>Django Celery Integration.</p>
<div class="section" id="module-djcelery.admin">
<span id="admin"></span><h2>Admin<a class="headerlink" href="#module-djcelery.admin" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-djcelery.admin_utils">
<span id="admin-utils"></span><h2>Admin Utils<a class="headerlink" href="#module-djcelery.admin_utils" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-djcelery.app">
<span id="app"></span><h2>APP<a class="headerlink" href="#module-djcelery.app" title="Permalink to this headline"></a></h2>
<dl class="data">
<dt id="djcelery.app.app">
<tt class="descclassname">djcelery.app.</tt><tt class="descname">app</tt><em class="property"> = &lt;Celery: default:0x107591310&gt;</em><a class="headerlink" href="#djcelery.app.app" title="Permalink to this definition"></a></dt>
<dd><p>The Django-Celery app instance.</p>
</dd></dl>

</div>
<div class="section" id="module-djcelery.loaders">
<span id="loaders"></span><h2>Loaders<a class="headerlink" href="#module-djcelery.loaders" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="djcelery.loaders.DjangoLoader">
<em class="property">class </em><tt class="descclassname">djcelery.loaders.</tt><tt class="descname">DjangoLoader</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/djcelery/loaders.html#DjangoLoader"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.loaders.DjangoLoader" title="Permalink to this definition"></a></dt>
<dd><p>The Django loader.</p>
<dl class="method">
<dt id="djcelery.loaders.DjangoLoader.on_process_cleanup">
<tt class="descname">on_process_cleanup</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/djcelery/loaders.html#DjangoLoader.on_process_cleanup"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.loaders.DjangoLoader.on_process_cleanup" title="Permalink to this definition"></a></dt>
<dd><p>Does everything necessary for Django to work in a long-living,
multiprocessing environment.</p>
</dd></dl>

<dl class="method">
<dt id="djcelery.loaders.DjangoLoader.on_task_init">
<tt class="descname">on_task_init</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/djcelery/loaders.html#DjangoLoader.on_task_init"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.loaders.DjangoLoader.on_task_init" title="Permalink to this definition"></a></dt>
<dd><p>Called before every task.</p>
</dd></dl>

<dl class="method">
<dt id="djcelery.loaders.DjangoLoader.on_worker_init">
<tt class="descname">on_worker_init</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/djcelery/loaders.html#DjangoLoader.on_worker_init"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.loaders.DjangoLoader.on_worker_init" title="Permalink to this definition"></a></dt>
<dd><p>Called when the worker starts.</p>
<p>Automatically discovers any <tt class="docutils literal"><span class="pre">tasks.py</span></tt> files in the applications
listed in <tt class="docutils literal"><span class="pre">INSTALLED_APPS</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="djcelery.loaders.DjangoLoader.read_configuration">
<tt class="descname">read_configuration</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/djcelery/loaders.html#DjangoLoader.read_configuration"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.loaders.DjangoLoader.read_configuration" title="Permalink to this definition"></a></dt>
<dd><p>Load configuration from Django settings.</p>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="djcelery.loaders.autodiscover">
<tt class="descclassname">djcelery.loaders.</tt><tt class="descname">autodiscover</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/djcelery/loaders.html#autodiscover"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.loaders.autodiscover" title="Permalink to this definition"></a></dt>
<dd><p>Include tasks for all applications in <tt class="docutils literal"><span class="pre">INSTALLED_APPS</span></tt>.</p>
</dd></dl>

<dl class="function">
<dt id="djcelery.loaders.find_related_module">
<tt class="descclassname">djcelery.loaders.</tt><tt class="descname">find_related_module</tt><big>(</big><em>app</em>, <em>related_name</em><big>)</big><a class="reference internal" href="_modules/djcelery/loaders.html#find_related_module"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.loaders.find_related_module" title="Permalink to this definition"></a></dt>
<dd><p>Given an application name and a module name, tries to find that
module in the application.</p>
</dd></dl>

</div>
<div class="section" id="module-djcelery.models">
<span id="models"></span><h2>Models<a class="headerlink" href="#module-djcelery.models" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="djcelery.models.CrontabSchedule">
<em class="property">class </em><tt class="descclassname">djcelery.models.</tt><tt class="descname">CrontabSchedule</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/djcelery/models.html#CrontabSchedule"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.models.CrontabSchedule" title="Permalink to this definition"></a></dt>
<dd><p>CrontabSchedule(id, minute, hour, day_of_week)</p>
</dd></dl>

<dl class="class">
<dt id="djcelery.models.IntervalSchedule">
<em class="property">class </em><tt class="descclassname">djcelery.models.</tt><tt class="descname">IntervalSchedule</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/djcelery/models.html#IntervalSchedule"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.models.IntervalSchedule" title="Permalink to this definition"></a></dt>
<dd><p>IntervalSchedule(id, every, period)</p>
</dd></dl>

<dl class="class">
<dt id="djcelery.models.PeriodicTask">
<em class="property">class </em><tt class="descclassname">djcelery.models.</tt><tt class="descname">PeriodicTask</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/djcelery/models.html#PeriodicTask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.models.PeriodicTask" title="Permalink to this definition"></a></dt>
<dd><p>PeriodicTask(id, name, task, interval_id, crontab_id, args, kwargs, queue, exchange, routing_key, expires, enabled, last_run_at, total_run_count, date_changed)</p>
</dd></dl>

<dl class="class">
<dt id="djcelery.models.PeriodicTasks">
<em class="property">class </em><tt class="descclassname">djcelery.models.</tt><tt class="descname">PeriodicTasks</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/djcelery/models.html#PeriodicTasks"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.models.PeriodicTasks" title="Permalink to this definition"></a></dt>
<dd><p>PeriodicTasks(ident, last_update)</p>
</dd></dl>

<dl class="class">
<dt id="djcelery.models.TaskMeta">
<em class="property">class </em><tt class="descclassname">djcelery.models.</tt><tt class="descname">TaskMeta</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/djcelery/models.html#TaskMeta"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.models.TaskMeta" title="Permalink to this definition"></a></dt>
<dd><p>Task result/status.</p>
</dd></dl>

<dl class="class">
<dt id="djcelery.models.TaskSetMeta">
<em class="property">class </em><tt class="descclassname">djcelery.models.</tt><tt class="descname">TaskSetMeta</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/djcelery/models.html#TaskSetMeta"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.models.TaskSetMeta" title="Permalink to this definition"></a></dt>
<dd><p>TaskSet result</p>
</dd></dl>

<dl class="class">
<dt id="djcelery.models.TaskState">
<em class="property">class </em><tt class="descclassname">djcelery.models.</tt><tt class="descname">TaskState</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/djcelery/models.html#TaskState"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.models.TaskState" title="Permalink to this definition"></a></dt>
<dd><p>TaskState(id, state, task_id, name, tstamp, args, kwargs, eta, expires, result, traceback, runtime, retries, worker_id, hidden)</p>
</dd></dl>

<dl class="class">
<dt id="djcelery.models.WorkerState">
<em class="property">class </em><tt class="descclassname">djcelery.models.</tt><tt class="descname">WorkerState</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/djcelery/models.html#WorkerState"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.models.WorkerState" title="Permalink to this definition"></a></dt>
<dd><p>WorkerState(id, hostname, last_heartbeat)</p>
</dd></dl>

<dl class="attribute">
<dt id="djcelery.models.result_model">
<tt class="descclassname">djcelery.models.</tt><tt class="descname">result_model</tt><a class="headerlink" href="#djcelery.models.result_model" title="Permalink to this definition"></a></dt>
<dd><p>alias of <a class="reference internal" href="#djcelery.models.TaskSetMeta" title="djcelery.models.TaskSetMeta"><tt class="xref py py-class docutils literal"><span class="pre">TaskSetMeta</span></tt></a></p>
</dd></dl>

</div>
<div class="section" id="module-djcelery.mon">
<span id="mon"></span><h2>Mon<a class="headerlink" href="#module-djcelery.mon" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="scheduler">
<h2>Scheduler<a class="headerlink" href="#scheduler" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-djcelery.snapshot">
<span id="snapshot"></span><h2>Snapshot<a class="headerlink" href="#module-djcelery.snapshot" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-djcelery.urls">
<span id="urls"></span><h2>Urls<a class="headerlink" href="#module-djcelery.urls" title="Permalink to this headline"></a></h2>
<p>URLs defined for celery.</p>
<ul>
<li><p class="first"><tt class="docutils literal"><span class="pre">/$task_id/done/</span></tt></p>
<blockquote>
<div><p>URL to <tt class="xref py py-func docutils literal"><span class="pre">is_successful()</span></tt>.</p>
</div></blockquote>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">/$task_id/status/</span></tt></p>
<blockquote>
<div><p>URL  to <tt class="xref py py-func docutils literal"><span class="pre">task_status()</span></tt>.</p>
</div></blockquote>
</li>
</ul>
</div>
<div class="section" id="module-djcelery.utils">
<span id="utils"></span><h2>Utils<a class="headerlink" href="#module-djcelery.utils" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt id="djcelery.utils.naturaldate">
<tt class="descclassname">djcelery.utils.</tt><tt class="descname">naturaldate</tt><big>(</big><em>date</em><big>)</big><a class="reference internal" href="_modules/djcelery/utils.html#naturaldate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.utils.naturaldate" title="Permalink to this definition"></a></dt>
<dd><p>Convert datetime into a human natural date string.</p>
</dd></dl>

</div>
<div class="section" id="module-djcelery.views">
<span id="views"></span><h2>Views<a class="headerlink" href="#module-djcelery.views" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt id="djcelery.views.apply">
<tt class="descclassname">djcelery.views.</tt><tt class="descname">apply</tt><big>(</big><em>request</em>, <em>task_name</em><big>)</big><a class="reference internal" href="_modules/djcelery/views.html#apply"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.views.apply" title="Permalink to this definition"></a></dt>
<dd><p>View applying a task.</p>
<dl class="docutils">
<dt><strong>Note:</strong> Please use this with caution. Preferably you shouldn&#8217;t make this</dt>
<dd>publicly accessible without ensuring your code is safe!</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="djcelery.views.is_task_successful">
<tt class="descclassname">djcelery.views.</tt><tt class="descname">is_task_successful</tt><big>(</big><em>request</em>, <em>task_id</em><big>)</big><a class="reference internal" href="_modules/djcelery/views.html#is_task_successful"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.views.is_task_successful" title="Permalink to this definition"></a></dt>
<dd><p>Returns task execute status in JSON format.</p>
</dd></dl>

<dl class="function">
<dt id="djcelery.views.registered_tasks">
<tt class="descclassname">djcelery.views.</tt><tt class="descname">registered_tasks</tt><big>(</big><em>request</em><big>)</big><a class="reference internal" href="_modules/djcelery/views.html#registered_tasks"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.views.registered_tasks" title="Permalink to this definition"></a></dt>
<dd><p>A view returning all defined tasks as a JSON object.</p>
</dd></dl>

<dl class="function">
<dt id="djcelery.views.task_status">
<tt class="descclassname">djcelery.views.</tt><tt class="descname">task_status</tt><big>(</big><em>request</em>, <em>task_id</em><big>)</big><a class="reference internal" href="_modules/djcelery/views.html#task_status"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.views.task_status" title="Permalink to this definition"></a></dt>
<dd><p>Returns task status and result in JSON format.</p>
</dd></dl>

<dl class="function">
<dt id="djcelery.views.task_view">
<tt class="descclassname">djcelery.views.</tt><tt class="descname">task_view</tt><big>(</big><em>task</em><big>)</big><a class="reference internal" href="_modules/djcelery/views.html#task_view"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.views.task_view" title="Permalink to this definition"></a></dt>
<dd><p>Decorator turning any task into a view that applies the task
asynchronously. Keyword arguments (via URLconf, etc.) will
supercede GET or POST parameters when there are conflicts.</p>
<dl class="docutils">
<dt>Returns a JSON dictionary containing the keys <tt class="docutils literal"><span class="pre">ok</span></tt>, and</dt>
<dd><tt class="docutils literal"><span class="pre">task_id</span></tt>.</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="djcelery.views.task_webhook">
<tt class="descclassname">djcelery.views.</tt><tt class="descname">task_webhook</tt><big>(</big><em>fun</em><big>)</big><a class="reference internal" href="_modules/djcelery/views.html#task_webhook"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#djcelery.views.task_webhook" title="Permalink to this definition"></a></dt>
<dd><p>Decorator turning a function into a task webhook.</p>
<p>If an exception is raised within the function, the decorated
function catches this and returns an error JSON response, otherwise
it returns the result as a JSON response.</p>
<p>Example:</p>
<div class="highlight-python"><pre>@task_webhook
def add(request):
    x = int(request.GET["x"])
    y = int(request.GET["y"])
    return x + y

&gt;&gt;&gt; response = add(request)
&gt;&gt;&gt; response.content
'{"status": "success", "retval": 100}'</pre>
</div>
</dd></dl>

</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 internal" href="#">The Django Celery Module</a><ul>
<li><a class="reference internal" href="#module-djcelery.admin">Admin</a></li>
<li><a class="reference internal" href="#module-djcelery.admin_utils">Admin Utils</a></li>
<li><a class="reference internal" href="#module-djcelery.app">APP</a></li>
<li><a class="reference internal" href="#module-djcelery.loaders">Loaders</a></li>
<li><a class="reference internal" href="#module-djcelery.models">Models</a></li>
<li><a class="reference internal" href="#module-djcelery.mon">Mon</a></li>
<li><a class="reference internal" href="#scheduler">Scheduler</a></li>
<li><a class="reference internal" href="#module-djcelery.snapshot">Snapshot</a></li>
<li><a class="reference internal" href="#module-djcelery.urls">Urls</a></li>
<li><a class="reference internal" href="#module-djcelery.utils">Utils</a></li>
<li><a class="reference internal" href="#module-djcelery.views">Views</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="social_auth.html"
                        title="previous chapter">The User Social Auth Module</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="twitter.html"
                        title="next chapter">The Twitter Module</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/djcelery.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" />
      <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="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="twitter.html" title="The Twitter Module"
             >next</a> |</li>
        <li class="right" >
          <a href="social_auth.html" title="The User Social Auth Module"
             >previous</a> |</li>
        <li><a href="index.html">EggDiscover 0.1 documentation</a> &raquo;</li>
          <li><a href="externalapps.html" >External apps used in this project</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Yohann Gabory.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
    </div>
  </body>
</html>