celery.datastructures.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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>Datastructures - celery.datastructures &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="Logging - celery.log" href="celery.log.html" />
  23. <link rel="prev" title="Configuration - celery.conf" href="celery.conf.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.log.html" title="Logging - celery.log"
  37. accesskey="N">next</a> |</li>
  38. <li class="right" >
  39. <a href="celery.conf.html" title="Configuration - celery.conf"
  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.datastructures">
  50. <h1>Datastructures - celery.datastructures<a class="headerlink" href="#module-celery.datastructures" title="Permalink to this headline">¶</a></h1>
  51. <p>Custom Datastructures</p>
  52. <dl class="class">
  53. <dt id="celery.datastructures.ExceptionInfo">
  54. <em class="property">
  55. class </em><tt class="descclassname">celery.datastructures.</tt><tt class="descname">ExceptionInfo</tt><big>(</big><em>exc_info</em><big>)</big><a class="headerlink" href="#celery.datastructures.ExceptionInfo" title="Permalink to this definition">¶</a></dt>
  56. <dd><p>Exception wrapping an exception and its traceback.</p>
  57. <table class="docutils field-list" frame="void" rules="none">
  58. <col class="field-name" />
  59. <col class="field-body" />
  60. <tbody valign="top">
  61. <tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>exc_info</em> &#8211; The exception tuple info as returned by
  62. <tt class="xref docutils literal"><span class="pre">traceback.format_exception()</span></tt>.</td>
  63. </tr>
  64. </tbody>
  65. </table>
  66. <dl class="attribute">
  67. <dt id="celery.datastructures.ExceptionInfo.exception">
  68. <tt class="descname">exception</tt><a class="headerlink" href="#celery.datastructures.ExceptionInfo.exception" title="Permalink to this definition">¶</a></dt>
  69. <dd>The original exception.</dd></dl>
  70. <dl class="attribute">
  71. <dt id="celery.datastructures.ExceptionInfo.traceback">
  72. <tt class="descname">traceback</tt><a class="headerlink" href="#celery.datastructures.ExceptionInfo.traceback" title="Permalink to this definition">¶</a></dt>
  73. <dd>A traceback from the point when <a title="celery.datastructures.ExceptionInfo.exception" class="reference internal" href="#celery.datastructures.ExceptionInfo.exception"><tt class="xref docutils literal"><span class="pre">exception</span></tt></a> was raised.</dd></dl>
  74. </dd></dl>
  75. <dl class="class">
  76. <dt id="celery.datastructures.PositionQueue">
  77. <em class="property">
  78. class </em><tt class="descclassname">celery.datastructures.</tt><tt class="descname">PositionQueue</tt><big>(</big><em>length</em><big>)</big><a class="headerlink" href="#celery.datastructures.PositionQueue" title="Permalink to this definition">¶</a></dt>
  79. <dd><p>A positional queue of a specific length, with slots that are either
  80. filled or unfilled. When all of the positions are filled, the queue
  81. is considered <a title="celery.datastructures.PositionQueue.full" class="reference internal" href="#celery.datastructures.PositionQueue.full"><tt class="xref docutils literal"><span class="pre">full()</span></tt></a>.</p>
  82. <table class="docutils field-list" frame="void" rules="none">
  83. <col class="field-name" />
  84. <col class="field-body" />
  85. <tbody valign="top">
  86. <tr class="field"><th class="field-name">Parameter:</th><td class="field-body"><em>length</em> &#8211; see <a title="celery.datastructures.PositionQueue.length" class="reference internal" href="#celery.datastructures.PositionQueue.length"><tt class="xref docutils literal"><span class="pre">length</span></tt></a>.</td>
  87. </tr>
  88. </tbody>
  89. </table>
  90. <dl class="attribute">
  91. <dt id="celery.datastructures.PositionQueue.length">
  92. <tt class="descname">length</tt><a class="headerlink" href="#celery.datastructures.PositionQueue.length" title="Permalink to this definition">¶</a></dt>
  93. <dd>The number of items required for the queue to be considered full.</dd></dl>
  94. <dl class="class">
  95. <dt id="celery.datastructures.PositionQueue.UnfilledPosition">
  96. <em class="property">
  97. class </em><tt class="descname">UnfilledPosition</tt><big>(</big><em>position</em><big>)</big><a class="headerlink" href="#celery.datastructures.PositionQueue.UnfilledPosition" title="Permalink to this definition">¶</a></dt>
  98. <dd>Describes an unfilled slot.</dd></dl>
  99. <dl class="attribute">
  100. <dt id="celery.datastructures.PositionQueue.filled">
  101. <tt class="descclassname">PositionQueue.</tt><tt class="descname">filled</tt><a class="headerlink" href="#celery.datastructures.PositionQueue.filled" title="Permalink to this definition">¶</a></dt>
  102. <dd>Returns the filled slots as a list.</dd></dl>
  103. <dl class="method">
  104. <dt id="celery.datastructures.PositionQueue.full">
  105. <tt class="descclassname">PositionQueue.</tt><tt class="descname">full</tt><big>(</big><big>)</big><a class="headerlink" href="#celery.datastructures.PositionQueue.full" title="Permalink to this definition">¶</a></dt>
  106. <dd>Returns <tt class="xref docutils literal"><span class="pre">True</span></tt> if all of the slots has been filled.</dd></dl>
  107. </dd></dl>
  108. <dl class="class">
  109. <dt id="celery.datastructures.SharedCounter">
  110. <em class="property">
  111. class </em><tt class="descclassname">celery.datastructures.</tt><tt class="descname">SharedCounter</tt><big>(</big><em>initial_value</em><big>)</big><a class="headerlink" href="#celery.datastructures.SharedCounter" title="Permalink to this definition">¶</a></dt>
  112. <dd><p>An integer that can be updated by several threads at once.</p>
  113. <p>Please note that the final value is not synchronized, this means
  114. that you should not update the value by using a previous value, the only
  115. reliable operations are increment and decrement.</p>
  116. <p>Example</p>
  117. <blockquote>
  118. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">max_clients</span> <span class="o">=</span> <span class="n">SharedCounter</span><span class="p">(</span><span class="n">initial_value</span><span class="o">=</span><span class="mf">10</span><span class="p">)</span>
  119. </pre></div>
  120. </div>
  121. <p># Thread one
  122. &gt;&gt;&gt; max_clients += 1 # OK (safe)</p>
  123. <p># Thread two
  124. &gt;&gt;&gt; max_clients -= 3 # OK (safe)</p>
  125. <p># Main thread
  126. &gt;&gt;&gt; if client &gt;= int(max_clients): # Max clients now at 8
  127. ... wait()</p>
  128. <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">max_client</span> <span class="o">=</span> <span class="n">max_clients</span> <span class="o">+</span> <span class="mf">10</span> <span class="c"># NOT OK (unsafe)</span>
  129. </pre></div>
  130. </div>
  131. </blockquote>
  132. <dl class="method">
  133. <dt id="celery.datastructures.SharedCounter.decrement">
  134. <tt class="descname">decrement</tt><big>(</big><em>n=1</em><big>)</big><a class="headerlink" href="#celery.datastructures.SharedCounter.decrement" title="Permalink to this definition">¶</a></dt>
  135. <dd>Decrement value.</dd></dl>
  136. <dl class="method">
  137. <dt id="celery.datastructures.SharedCounter.increment">
  138. <tt class="descname">increment</tt><big>(</big><em>n=1</em><big>)</big><a class="headerlink" href="#celery.datastructures.SharedCounter.increment" title="Permalink to this definition">¶</a></dt>
  139. <dd>Increment value.</dd></dl>
  140. </dd></dl>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. <div class="sphinxsidebar">
  146. <div class="sphinxsidebarwrapper">
  147. <h4>Previous topic</h4>
  148. <p class="topless"><a href="celery.conf.html"
  149. title="previous chapter">Configuration - celery.conf</a></p>
  150. <h4>Next topic</h4>
  151. <p class="topless"><a href="celery.log.html"
  152. title="next chapter">Logging - celery.log</a></p>
  153. <h3>This Page</h3>
  154. <ul class="this-page-menu">
  155. <li><a href="../sources/reference/celery.datastructures.txt"
  156. rel="nofollow">Show Source</a></li>
  157. </ul>
  158. <div id="searchbox" style="display: none">
  159. <h3>Quick search</h3>
  160. <form class="search" action="../search.html" method="get">
  161. <input type="text" name="q" size="18" />
  162. <input type="submit" value="Go" />
  163. <input type="hidden" name="check_keywords" value="yes" />
  164. <input type="hidden" name="area" value="default" />
  165. </form>
  166. <p class="searchtip" style="font-size: 90%">
  167. Enter search terms or a module, class or function name.
  168. </p>
  169. </div>
  170. <script type="text/javascript">$('#searchbox').show(0);</script>
  171. </div>
  172. </div>
  173. <div class="clearer"></div>
  174. </div>
  175. <div class="related">
  176. <h3>Navigation</h3>
  177. <ul>
  178. <li class="right" style="margin-right: 10px">
  179. <a href="../genindex.html" title="General Index"
  180. >index</a></li>
  181. <li class="right" >
  182. <a href="../modindex.html" title="Global Module Index"
  183. >modules</a> |</li>
  184. <li class="right" >
  185. <a href="celery.log.html" title="Logging - celery.log"
  186. >next</a> |</li>
  187. <li class="right" >
  188. <a href="celery.conf.html" title="Configuration - celery.conf"
  189. >previous</a> |</li>
  190. <li><a href="../index.html">Celery v0.7.0 (unstable) documentation</a> &raquo;</li>
  191. <li><a href="index.html" >Module API Reference</a> &raquo;</li>
  192. </ul>
  193. </div>
  194. <div class="footer">
  195. &copy; Copyright 2009, Ask Solem.
  196. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.2.
  197. </div>
  198. </body>
  199. </html>