| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 | <!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>Multiprocessing Worker - celery.worker — 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="up" title="Module API Reference" href="index.html" />    <link rel="next" title="Django Views - celery.views" href="celery.views.html" />    <link rel="prev" title="Logging - celery.log" href="celery.log.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="celery.views.html" title="Django Views - celery.views"             accesskey="N">next</a> |</li>        <li class="right" >          <a href="celery.log.html" title="Logging - celery.log"             accesskey="P">previous</a> |</li>        <li><a href="../index.html">Celery v0.7.0 (unstable) documentation</a> »</li>          <li><a href="index.html" accesskey="U">Module API Reference</a> »</li>       </ul>    </div>      <div class="document">      <div class="documentwrapper">        <div class="bodywrapper">          <div class="body">              <div class="section" id="module-celery.utils"><h1>Multiprocessing Worker - celery.worker<a class="headerlink" href="#module-celery.utils" title="Permalink to this headline">¶</a></h1><p>Utility functions</p><dl class="function"><dt id="celery.utils.chunks"><tt class="descclassname">celery.utils.</tt><tt class="descname">chunks</tt><big>(</big><em>it</em>, <em>n</em><big>)</big><a class="headerlink" href="#celery.utils.chunks" title="Permalink to this definition">¶</a></dt><dd><p>Split an iterator into chunks with <tt class="docutils literal"><span class="pre">n</span></tt> elements each.</p><p>Examples</p><blockquote><p># n == 2>>> x = chunks(iter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 2)>>> list(x)[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10]]</p><p># n == 3>>> x = chunks(iter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 3)>>> list(x)[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10]]</p></blockquote></dd></dl><dl class="function"><dt id="celery.utils.gen_unique_id"><tt class="descclassname">celery.utils.</tt><tt class="descname">gen_unique_id</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.utils.gen_unique_id" title="Permalink to this definition">¶</a></dt><dd><p>Generate a unique id, having - hopefully - a very small chance ofcollission.</p><p>For now this is provided by <tt class="xref docutils literal"><span class="pre">uuid.uuid4()</span></tt>.</p></dd></dl><dl class="function"><dt id="celery.utils.get_full_cls_name"><tt class="descclassname">celery.utils.</tt><tt class="descname">get_full_cls_name</tt><big>(</big><em>cls</em><big>)</big><a class="headerlink" href="#celery.utils.get_full_cls_name" title="Permalink to this definition">¶</a></dt><dd>With a class, get its full module and class name.</dd></dl><dl class="function"><dt id="celery.utils.mitemgetter"><tt class="descclassname">celery.utils.</tt><tt class="descname">mitemgetter</tt><big>(</big><em>*keys</em><big>)</big><a class="headerlink" href="#celery.utils.mitemgetter" title="Permalink to this definition">¶</a></dt><dd>Like <tt class="xref docutils literal"><span class="pre">operator.itemgetter()</span></tt> but returns <cite>None</cite> on missing keysinstead of raising <tt class="xref docutils literal"><span class="pre">KeyError</span></tt>.</dd></dl><dl class="function"><dt id="celery.utils.repeatlast"><tt class="descclassname">celery.utils.</tt><tt class="descname">repeatlast</tt><big>(</big><em>it</em><big>)</big><a class="headerlink" href="#celery.utils.repeatlast" title="Permalink to this definition">¶</a></dt><dd>Iterate over all elements in the iterator, and when its exhaustedyield the last value infinitely.</dd></dl><dl class="function"><dt id="celery.utils.retry_over_time"><tt class="descclassname">celery.utils.</tt><tt class="descname">retry_over_time</tt><big>(</big><em>fun</em>, <em>catch</em>, <em>args=</em><span class="optional">[</span><span class="optional">]</span>, <em>kwargs={}</em>, <em>errback=<function <lambda> at 0x21b6af0></em>, <em>max_retries=None</em>, <em>interval_start=2</em>, <em>interval_step=2</em>, <em>interval_max=30</em><big>)</big><a class="headerlink" href="#celery.utils.retry_over_time" title="Permalink to this definition">¶</a></dt><dd><p>Retry the function over and over until max retries is exceeded.</p><p>For each retry we sleep a for a while before we try again, this intervalis increased for every retry until the max seconds is reached.</p><table class="docutils field-list" frame="void" rules="none"><col class="field-name" /><col class="field-body" /><tbody valign="top"><tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"><li><em>fun</em> – The function to try</li><li><em>catch</em> – Exceptions to catch, can be either tuple or a singleexception class.</li><li><em>args</em> – Positional arguments passed on to the function.</li><li><em>kwargs</em> – Keyword arguments passed on to the function.</li><li><em>errback</em> – Callback for when an exception in <tt class="docutils literal"><span class="pre">catch</span></tt> is raised.The callback must take two arguments: <tt class="docutils literal"><span class="pre">exc</span></tt> and <tt class="docutils literal"><span class="pre">interval</span></tt>, where<tt class="docutils literal"><span class="pre">exc</span></tt> is the exception instance, and <tt class="docutils literal"><span class="pre">interval</span></tt> is the time inseconds to sleep next..</li><li><em>max_retries</em> – Maximum number of retries before we give up.If this is not set, we will retry forever.</li><li><em>interval_start</em> – How long (in seconds) we start sleeping betweenretries.</li><li><em>interval_step</em> – By how much the interval is increased for eachretry.</li><li><em>interval_max</em> – Maximum number of seconds to sleep between retries.</li></ul></td></tr></tbody></table></dd></dl></div>          </div>        </div>      </div>      <div class="sphinxsidebar">        <div class="sphinxsidebarwrapper">            <h4>Previous topic</h4>            <p class="topless"><a href="celery.log.html"                                  title="previous chapter">Logging - celery.log</a></p>            <h4>Next topic</h4>            <p class="topless"><a href="celery.views.html"                                  title="next chapter">Django Views - celery.views</a></p>            <h3>This Page</h3>            <ul class="this-page-menu">              <li><a href="../sources/reference/celery.utils.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="celery.views.html" title="Django Views - celery.views"             >next</a> |</li>        <li class="right" >          <a href="celery.log.html" title="Logging - celery.log"             >previous</a> |</li>        <li><a href="../index.html">Celery v0.7.0 (unstable) documentation</a> »</li>          <li><a href="index.html" >Module API Reference</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>
 |