celery.utils.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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>Multiprocessing Worker - celery.worker &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="up" title="Module API Reference" href="index.html" />
  22. <link rel="next" title="Django Views - celery.views" href="celery.views.html" />
  23. <link rel="prev" title="Logging - celery.log" href="celery.log.html" />
  24. </head>
  25. <body>
  26. <div class="related">
  27. <h3>Navigation</h3>
  28. <ul>
  29. <li class="right" style="margin-right: 10px">
  30. <a href="../genindex.html" title="General Index"
  31. accesskey="I">index</a></li>
  32. <li class="right" >
  33. <a href="../modindex.html" title="Global Module Index"
  34. accesskey="M">modules</a> |</li>
  35. <li class="right" >
  36. <a href="celery.views.html" title="Django Views - celery.views"
  37. accesskey="N">next</a> |</li>
  38. <li class="right" >
  39. <a href="celery.log.html" title="Logging - celery.log"
  40. accesskey="P">previous</a> |</li>
  41. <li><a href="../index.html">Celery v0.7.0 (unstable) documentation</a> &raquo;</li>
  42. <li><a href="index.html" accesskey="U">Module API Reference</a> &raquo;</li>
  43. </ul>
  44. </div>
  45. <div class="document">
  46. <div class="documentwrapper">
  47. <div class="bodywrapper">
  48. <div class="body">
  49. <div class="section" id="module-celery.utils">
  50. <h1>Multiprocessing Worker - celery.worker<a class="headerlink" href="#module-celery.utils" title="Permalink to this headline">¶</a></h1>
  51. <p>Utility functions</p>
  52. <dl class="function">
  53. <dt id="celery.utils.chunks">
  54. <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>
  55. <dd><p>Split an iterator into chunks with <tt class="docutils literal"><span class="pre">n</span></tt> elements each.</p>
  56. <p>Examples</p>
  57. <blockquote>
  58. <p># n == 2
  59. &gt;&gt;&gt; x = chunks(iter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 2)
  60. &gt;&gt;&gt; list(x)
  61. [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10]]</p>
  62. <p># n == 3
  63. &gt;&gt;&gt; x = chunks(iter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 3)
  64. &gt;&gt;&gt; list(x)
  65. [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10]]</p>
  66. </blockquote>
  67. </dd></dl>
  68. <dl class="function">
  69. <dt id="celery.utils.gen_unique_id">
  70. <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>
  71. <dd><p>Generate a unique id, having - hopefully - a very small chance of
  72. collission.</p>
  73. <p>For now this is provided by <tt class="xref docutils literal"><span class="pre">uuid.uuid4()</span></tt>.</p>
  74. </dd></dl>
  75. <dl class="function">
  76. <dt id="celery.utils.get_full_cls_name">
  77. <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>
  78. <dd>With a class, get its full module and class name.</dd></dl>
  79. <dl class="function">
  80. <dt id="celery.utils.mitemgetter">
  81. <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>
  82. <dd>Like <tt class="xref docutils literal"><span class="pre">operator.itemgetter()</span></tt> but returns <cite>None</cite> on missing keys
  83. instead of raising <tt class="xref docutils literal"><span class="pre">KeyError</span></tt>.</dd></dl>
  84. <dl class="function">
  85. <dt id="celery.utils.repeatlast">
  86. <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>
  87. <dd>Iterate over all elements in the iterator, and when its exhausted
  88. yield the last value infinitely.</dd></dl>
  89. <dl class="function">
  90. <dt id="celery.utils.retry_over_time">
  91. <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=&lt;function &lt;lambda&gt; at 0x21b6af0&gt;</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>
  92. <dd><p>Retry the function over and over until max retries is exceeded.</p>
  93. <p>For each retry we sleep a for a while before we try again, this interval
  94. is increased for every retry until the max seconds is reached.</p>
  95. <table class="docutils field-list" frame="void" rules="none">
  96. <col class="field-name" />
  97. <col class="field-body" />
  98. <tbody valign="top">
  99. <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  100. <li><em>fun</em> &#8211; The function to try</li>
  101. <li><em>catch</em> &#8211; Exceptions to catch, can be either tuple or a single
  102. exception class.</li>
  103. <li><em>args</em> &#8211; Positional arguments passed on to the function.</li>
  104. <li><em>kwargs</em> &#8211; Keyword arguments passed on to the function.</li>
  105. <li><em>errback</em> &#8211; Callback for when an exception in <tt class="docutils literal"><span class="pre">catch</span></tt> is raised.
  106. 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
  107. <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 in
  108. seconds to sleep next..</li>
  109. <li><em>max_retries</em> &#8211; Maximum number of retries before we give up.
  110. If this is not set, we will retry forever.</li>
  111. <li><em>interval_start</em> &#8211; How long (in seconds) we start sleeping between
  112. retries.</li>
  113. <li><em>interval_step</em> &#8211; By how much the interval is increased for each
  114. retry.</li>
  115. <li><em>interval_max</em> &#8211; Maximum number of seconds to sleep between retries.</li>
  116. </ul>
  117. </td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. </dd></dl>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. <div class="sphinxsidebar">
  127. <div class="sphinxsidebarwrapper">
  128. <h4>Previous topic</h4>
  129. <p class="topless"><a href="celery.log.html"
  130. title="previous chapter">Logging - celery.log</a></p>
  131. <h4>Next topic</h4>
  132. <p class="topless"><a href="celery.views.html"
  133. title="next chapter">Django Views - celery.views</a></p>
  134. <h3>This Page</h3>
  135. <ul class="this-page-menu">
  136. <li><a href="../sources/reference/celery.utils.txt"
  137. rel="nofollow">Show Source</a></li>
  138. </ul>
  139. <div id="searchbox" style="display: none">
  140. <h3>Quick search</h3>
  141. <form class="search" action="../search.html" method="get">
  142. <input type="text" name="q" size="18" />
  143. <input type="submit" value="Go" />
  144. <input type="hidden" name="check_keywords" value="yes" />
  145. <input type="hidden" name="area" value="default" />
  146. </form>
  147. <p class="searchtip" style="font-size: 90%">
  148. Enter search terms or a module, class or function name.
  149. </p>
  150. </div>
  151. <script type="text/javascript">$('#searchbox').show(0);</script>
  152. </div>
  153. </div>
  154. <div class="clearer"></div>
  155. </div>
  156. <div class="related">
  157. <h3>Navigation</h3>
  158. <ul>
  159. <li class="right" style="margin-right: 10px">
  160. <a href="../genindex.html" title="General Index"
  161. >index</a></li>
  162. <li class="right" >
  163. <a href="../modindex.html" title="Global Module Index"
  164. >modules</a> |</li>
  165. <li class="right" >
  166. <a href="celery.views.html" title="Django Views - celery.views"
  167. >next</a> |</li>
  168. <li class="right" >
  169. <a href="celery.log.html" title="Logging - celery.log"
  170. >previous</a> |</li>
  171. <li><a href="../index.html">Celery v0.7.0 (unstable) documentation</a> &raquo;</li>
  172. <li><a href="index.html" >Module API Reference</a> &raquo;</li>
  173. </ul>
  174. </div>
  175. <div class="footer">
  176. &copy; Copyright 2009, Ask Solem.
  177. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.2.
  178. </div>
  179. </body>
  180. </html>