summaryrefslogtreecommitdiff
path: root/reference/kombu.utils.html
blob: 5728c23a50d6fcad9e501da214a58391cc978d33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272

<!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>Utilities - kombu.utils &mdash; Kombu 2.1.3 documentation</title>
    
    <link rel="stylesheet" href="../_static/celery.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.1.3',
        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="Kombu 2.1.3 documentation" href="../index.html" />
    <link rel="up" title="API Reference" href="index.html" />
    <link rel="next" title="Rate limiting - kombu.utils.limits" href="kombu.utils.limits.html" />
    <link rel="prev" title="Async Utilities - kombu.syn" href="kombu.syn.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="kombu.utils.limits.html" title="Rate limiting - kombu.utils.limits"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="kombu.syn.html" title="Async Utilities - kombu.syn"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">Kombu 2.1.3 documentation</a> &raquo;</li>
          <li><a href="index.html" accesskey="U">API Reference</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="utilities-kombu-utils">
<h1>Utilities - kombu.utils<a class="headerlink" href="#utilities-kombu-utils" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#kombu-utils" id="id1">kombu.utils</a></li>
</ul>
</div>
<span class="target" id="module-kombu.utils"></span><div class="section" id="kombu-utils">
<h2><a class="toc-backref" href="#id1">kombu.utils</a><a class="headerlink" href="#kombu-utils" title="Permalink to this headline">¶</a></h2>
<p>Internal utilities.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">copyright:</th><td class="field-body"><ol class="first loweralpha simple" start="3">
<li>2009 - 2012 by Ask Solem.</li>
</ol>
</td>
</tr>
<tr class="field-even field"><th class="field-name">license:</th><td class="field-body"><p class="first last">BSD, see LICENSE for more details.</p>
</td>
</tr>
</tbody>
</table>
<dl class="class">
<dt id="kombu.utils.EqualityDict">
<em class="property">class </em><tt class="descclassname">kombu.utils.</tt><tt class="descname">EqualityDict</tt><a class="headerlink" href="#kombu.utils.EqualityDict" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="kombu.utils.say">
<tt class="descclassname">kombu.utils.</tt><tt class="descname">say</tt><big>(</big><em>m</em>, <em>*s</em><big>)</big><a class="headerlink" href="#kombu.utils.say" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="kombu.utils.uuid">
<tt class="descclassname">kombu.utils.</tt><tt class="descname">uuid</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.utils.uuid" title="Permalink to this definition">¶</a></dt>
<dd><p>Generate a unique id, having - hopefully - a very small chance of
collision.</p>
<p>For now this is provided by <tt class="xref py py-func docutils literal"><span class="pre">uuid.uuid4()</span></tt>.</p>
</dd></dl>

<dl class="function">
<dt id="kombu.utils.kwdict">
<tt class="descclassname">kombu.utils.</tt><tt class="descname">kwdict</tt><big>(</big><em>kwargs</em><big>)</big><a class="headerlink" href="#kombu.utils.kwdict" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="kombu.utils.maybe_list">
<tt class="descclassname">kombu.utils.</tt><tt class="descname">maybe_list</tt><big>(</big><em>v</em><big>)</big><a class="headerlink" href="#kombu.utils.maybe_list" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="kombu.utils.fxrange">
<tt class="descclassname">kombu.utils.</tt><tt class="descname">fxrange</tt><big>(</big><em>start=1.0</em>, <em>stop=None</em>, <em>step=1.0</em>, <em>repeatlast=False</em><big>)</big><a class="headerlink" href="#kombu.utils.fxrange" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="kombu.utils.fxrangemax">
<tt class="descclassname">kombu.utils.</tt><tt class="descname">fxrangemax</tt><big>(</big><em>start=1.0</em>, <em>stop=None</em>, <em>step=1.0</em>, <em>max=100.0</em><big>)</big><a class="headerlink" href="#kombu.utils.fxrangemax" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="kombu.utils.retry_over_time">
<tt class="descclassname">kombu.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=None</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="#kombu.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 interval
is 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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>fun</strong> &#8211; The function to try</li>
<li><strong>catch</strong> &#8211; Exceptions to catch, can be either tuple or a single
exception class.</li>
<li><strong>args</strong> &#8211; Positional arguments passed on to the function.</li>
<li><strong>kwargs</strong> &#8211; Keyword arguments passed on to the function.</li>
<li><strong>errback</strong> &#8211; 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 in
seconds to sleep next..</li>
<li><strong>max_retries</strong> &#8211; Maximum number of retries before we give up.
If this is not set, we will retry forever.</li>
<li><strong>interval_start</strong> &#8211; How long (in seconds) we start sleeping between
retries.</li>
<li><strong>interval_step</strong> &#8211; By how much the interval is increased for each
retry.</li>
<li><strong>interval_max</strong> &#8211; Maximum number of seconds to sleep between retries.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="kombu.utils.emergency_dump_state">
<tt class="descclassname">kombu.utils.</tt><tt class="descname">emergency_dump_state</tt><big>(</big><em>state</em>, <em>open_file=&lt;built-in function open&gt;</em>, <em>dump=None</em><big>)</big><a class="headerlink" href="#kombu.utils.emergency_dump_state" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="kombu.utils.cached_property">
<tt class="descclassname">kombu.utils.</tt><tt class="descname">cached_property</tt><a class="headerlink" href="#kombu.utils.cached_property" title="Permalink to this definition">¶</a></dt>
<dd><p>Property descriptor that caches the return value
of the get function.</p>
<p><em>Examples</em></p>
<div class="highlight-python"><div class="highlight"><pre><span class="nd">@cached_property</span>
<span class="k">def</span> <span class="nf">connection</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">Connection</span><span class="p">()</span>

<span class="nd">@connection.setter</span>  <span class="c"># Prepares stored value</span>
<span class="k">def</span> <span class="nf">connection</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s">&quot;Connection must be a connection&quot;</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">value</span>

<span class="nd">@connection.deleter</span>
<span class="k">def</span> <span class="nf">connection</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
    <span class="c"># Additional action to do at del(self.attr)</span>
    <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
        <span class="k">print</span><span class="p">(</span><span class="s">&quot;Connection </span><span class="si">%r</span><span class="s"> deleted&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="kombu.utils.reprkwargs">
<tt class="descclassname">kombu.utils.</tt><tt class="descname">reprkwargs</tt><big>(</big><em>kwargs</em>, <em>sep='</em>, <em>'</em>, <em>fmt='%s=%s'</em><big>)</big><a class="headerlink" href="#kombu.utils.reprkwargs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="kombu.utils.reprcall">
<tt class="descclassname">kombu.utils.</tt><tt class="descname">reprcall</tt><big>(</big><em>name</em>, <em>args=()</em>, <em>kwargs=()</em>, <em>sep='</em>, <em>'</em><big>)</big><a class="headerlink" href="#kombu.utils.reprcall" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="kombu.utils.nested">
<tt class="descclassname">kombu.utils.</tt><tt class="descname">nested</tt><big>(</big><em>*args</em>, <em>**kwds</em><big>)</big><a class="headerlink" href="#kombu.utils.nested" title="Permalink to this definition">¶</a></dt>
<dd><p>Combine multiple context managers into a single nested
context manager.</p>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper"><p class="logo"><a href="../index.html">
  <img class="logo" width="128" height="128" src="http://cloud.github.com/downloads/ask/kombu/kombusmall.jpg" alt="Logo"/>
</a></p>
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Utilities - kombu.utils</a><ul>
<li><a class="reference internal" href="#kombu-utils">kombu.utils</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="kombu.syn.html"
                        title="previous chapter">Async Utilities - kombu.syn</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="kombu.utils.limits.html"
                        title="next chapter">Rate limiting - kombu.utils.limits</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/reference/kombu.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" />
      <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="kombu.utils.limits.html" title="Rate limiting - kombu.utils.limits"
             >next</a> |</li>
        <li class="right" >
          <a href="kombu.syn.html" title="Async Utilities - kombu.syn"
             >previous</a> |</li>
        <li><a href="../index.html">Kombu 2.1.3 documentation</a> &raquo;</li>
          <li><a href="index.html" >API Reference</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2012, Ask Solem.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
    </div>
  </body>
</html>