summaryrefslogtreecommitdiff
path: root/reference/kombu.connection.html
blob: 7406bf7e2ba8c02ba8950e1c6137e8ff1f4d0a30 (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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571

<!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>kombu.connection &mdash; Kombu v1.0.6 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:     '1.0.6',
        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 v1.0.6 documentation" href="../index.html" />
    <link rel="up" title="API Reference" href="index.html" />
    <link rel="next" title="kombu.simple" href="kombu.simple.html" />
    <link rel="prev" title="API Reference" href="index.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.simple.html" title="kombu.simple"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="index.html" title="API Reference"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">Kombu v1.0.6 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">
            
  <span class="target" id="module-kombu.connection"></span><div class="section" id="kombu-connection">
<h1>kombu.connection<a class="headerlink" href="#kombu-connection" title="Permalink to this headline">¶</a></h1>
<p>Broker connection and pools.</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">copyright:</th><td class="field-body"><ol class="first loweralpha simple" start="3">
<li>2009 - 2011 by Ask Solem.</li>
</ol>
</td>
</tr>
<tr class="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>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#connection" id="id1">Connection</a></li>
<li><a class="reference internal" href="#pools" id="id2">Pools</a></li>
</ul>
</div>
<div class="section" id="connection">
<h2><a class="toc-backref" href="#id1">Connection</a><a class="headerlink" href="#connection" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="kombu.connection.BrokerConnection">
<em class="property">class </em><tt class="descclassname">kombu.connection.</tt><tt class="descname">BrokerConnection</tt><big>(</big><em>hostname='localhost'</em>, <em>userid='guest'</em>, <em>password='guest'</em>, <em>virtual_host='/'</em>, <em>port=None</em>, <em>insist=False</em>, <em>ssl=False</em>, <em>transport=None</em>, <em>connect_timeout=5</em>, <em>backend_cls=None</em><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection" title="Permalink to this definition">¶</a></dt>
<dd><p>A connection to the broker.</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><strong>hostname</strong> &#8211; Hostname/address of the server to connect to.
Default is <tt class="docutils literal"><span class="pre">&quot;localhost&quot;</span></tt>.</li>
<li><strong>userid</strong> &#8211; Username. Default is <tt class="docutils literal"><span class="pre">&quot;guest&quot;</span></tt>.</li>
<li><strong>password</strong> &#8211; Password. Default is <tt class="docutils literal"><span class="pre">&quot;guest&quot;</span></tt>.</li>
<li><strong>virtual_host</strong> &#8211; Virtual host. Default is <tt class="docutils literal"><span class="pre">&quot;/&quot;</span></tt>.</li>
<li><strong>port</strong> &#8211; Port of the server. Default is transport specific.</li>
<li><strong>insist</strong> &#8211; Insist on connecting to a server.
In a configuration with multiple load-sharing servers, the insist
option tells the server that the client is insisting on a connection
to the specified server.  Default is <tt class="xref docutils literal"><span class="pre">False</span></tt>.</li>
<li><strong>ssl</strong> &#8211; Use ssl to connect to the server. Default is <tt class="xref docutils literal"><span class="pre">False</span></tt>.</li>
<li><strong>transport</strong> &#8211; Transport class to use. Can be a class,
or a string specifying the path to the class. (e.g.
<tt class="docutils literal"><span class="pre">kombu.transport.pyamqplib.Transport</span></tt>), or one of the aliases:
<tt class="docutils literal"><span class="pre">amqplib</span></tt>, <tt class="docutils literal"><span class="pre">pika</span></tt>, <tt class="docutils literal"><span class="pre">redis</span></tt>, <tt class="docutils literal"><span class="pre">memory</span></tt>.</li>
<li><strong>connect_timeout</strong> &#8211; Timeout in seconds for connecting to the
server. May not be suported by the specified transport.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><strong>Usage</strong></p>
<p>Creating a connection:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">conn</span> <span class="o">=</span> <span class="n">BrokerConnection</span><span class="p">(</span><span class="s">&quot;rabbit.example.com&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>The connection is established lazily when needed. If you need the
connection to be established, then force it to do so using
<a class="reference internal" href="#kombu.connection.BrokerConnection.connect" title="kombu.connection.BrokerConnection.connect"><tt class="xref py py-meth docutils literal"><span class="pre">connect()</span></tt></a>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">conn</span><span class="o">.</span><span class="n">connect</span><span class="p">()</span>
</pre></div>
</div>
<p>Remember to always close the connection:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">conn</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
</pre></div>
</div>
<div class="admonition-attributes admonition ">
<p class="first admonition-title">Attributes</p>
<dl class="attribute">
<dt id="kombu.connection.BrokerConnection.connection_errors">
<tt class="descname">connection_errors</tt><a class="headerlink" href="#kombu.connection.BrokerConnection.connection_errors" title="Permalink to this definition">¶</a></dt>
<dd><p>List of exceptions that may be raised by the connection.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.connection.BrokerConnection.channel_errors">
<tt class="descname">channel_errors</tt><a class="headerlink" href="#kombu.connection.BrokerConnection.channel_errors" title="Permalink to this definition">¶</a></dt>
<dd><p>List of exceptions that may be raised by the channel.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.connection.BrokerConnection.transport">
<tt class="descname">transport</tt><a class="headerlink" href="#kombu.connection.BrokerConnection.transport" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="kombu.connection.BrokerConnection.host">
<tt class="descname">host</tt><a class="headerlink" href="#kombu.connection.BrokerConnection.host" title="Permalink to this definition">¶</a></dt>
<dd><p>The host as a hostname/port pair separated by colon.</p>
</dd></dl>

<dl class="last attribute">
<dt id="kombu.connection.BrokerConnection.connection">
<tt class="descname">connection</tt><a class="headerlink" href="#kombu.connection.BrokerConnection.connection" title="Permalink to this definition">¶</a></dt>
<dd><p>The underlying connection object.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This instance is transport specific, so do not
depend on the interface of this object.</p>
</div>
</dd></dl>

</div>
<div class="admonition-methods admonition ">
<p class="first admonition-title">Methods</p>
<dl class="method">
<dt id="kombu.connection.BrokerConnection.connect">
<tt class="descname">connect</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.connect" title="Permalink to this definition">¶</a></dt>
<dd><p>Establish connection to server immediately.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.channel">
<tt class="descname">channel</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.channel" title="Permalink to this definition">¶</a></dt>
<dd><p>Request a new channel.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.drain_events">
<tt class="descname">drain_events</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.drain_events" title="Permalink to this definition">¶</a></dt>
<dd><p>Wait for a single event from the server.</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><strong>timeout</strong> &#8211; Timeout in seconds before we give up.
Raises <tt class="xref py py-exc docutils literal"><span class="pre">socket.timeout</span></tt> if the timeout is execeded.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Usually used from an event loop.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.release">
<tt class="descname">release</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.release" title="Permalink to this definition">¶</a></dt>
<dd><p>Close the connection (if open).</p>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.ensure_connection">
<tt class="descname">ensure_connection</tt><big>(</big><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.connection.BrokerConnection.ensure_connection" title="Permalink to this definition">¶</a></dt>
<dd><p>Ensure we have a connection to the server.</p>
<p>If not retry establishing the connection with the settings
specified.</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><strong>errback</strong> &#8211; Optional callback called each time the connection
can&#8217;t be established. Arguments provided are the exception
raised and the interval that will be slept <tt class="docutils literal"><span class="pre">(exc,</span> <span class="pre">interval)</span></tt>.</li>
<li><strong>max_retries</strong> &#8211; Maximum number of times to retry.
If this limit is exceeded the connection error will be re-raised.</li>
<li><strong>interval_start</strong> &#8211; The number of seconds we start sleeping for.</li>
<li><strong>interval_step</strong> &#8211; How many seconds added to the interval
for each retry.</li>
<li><strong>interval_max</strong> &#8211; Maximum number of seconds to sleep between
each retry.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.ensure">
<tt class="descname">ensure</tt><big>(</big><em>obj</em>, <em>fun</em>, <em>errback=None</em>, <em>max_retries=None</em>, <em>interval_start=1</em>, <em>interval_step=1</em>, <em>interval_max=1</em><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.ensure" title="Permalink to this definition">¶</a></dt>
<dd><p>Ensure operation completes, regardless of any channel/connection
errors occuring.</p>
<p>Will retry by establishing the connection, and reapplying
the function.</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><strong>fun</strong> &#8211; Method to apply.</li>
<li><strong>errback</strong> &#8211; Optional callback called each time the connection
can&#8217;t be established. Arguments provided are the exception
raised and the interval that will be slept <tt class="docutils literal"><span class="pre">(exc,</span> <span class="pre">interval)</span></tt>.</li>
<li><strong>max_retries</strong> &#8211; Maximum number of times to retry.
If this limit is exceeded the connection error will be re-raised.</li>
<li><strong>interval_start</strong> &#8211; The number of seconds we start sleeping for.</li>
<li><strong>interval_step</strong> &#8211; How many seconds added to the interval
for each retry.</li>
<li><strong>interval_max</strong> &#8211; Maximum number of seconds to sleep between
each retry.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong></p>
<p>This is an example ensuring a publish operation:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">errback</span><span class="p">(</span><span class="n">exc</span><span class="p">,</span> <span class="n">interval</span><span class="p">):</span>
<span class="gp">... </span>    <span class="k">print</span><span class="p">(</span><span class="s">&quot;Couldn&#39;t publish message: </span><span class="si">%r</span><span class="s">. Retry in </span><span class="si">%d</span><span class="s">s&quot;</span> <span class="o">%</span> <span class="p">(</span>
<span class="gp">... </span>            <span class="n">exc</span><span class="p">,</span> <span class="n">interval</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">publish</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">ensure</span><span class="p">(</span><span class="n">producer</span><span class="p">,</span> <span class="n">producer</span><span class="o">.</span><span class="n">publish</span><span class="p">,</span>
<span class="gp">... </span>                      <span class="n">errback</span><span class="o">=</span><span class="n">errback</span><span class="p">,</span> <span class="n">max_retries</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">publish</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">routing_key</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.create_transport">
<tt class="descname">create_transport</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.create_transport" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.get_transport_cls">
<tt class="descname">get_transport_cls</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.get_transport_cls" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the currently used transport class.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.clone">
<tt class="descname">clone</tt><big>(</big><em>**kwargs</em><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.clone" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a copy of the connection with the same connection
settings.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.info">
<tt class="descname">info</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.info" title="Permalink to this definition">¶</a></dt>
<dd><p>Get connection info.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.Pool">
<tt class="descname">Pool</tt><big>(</big><em>limit=None</em>, <em>preload=None</em><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.Pool" title="Permalink to this definition">¶</a></dt>
<dd><p>Pool of connections.</p>
<p>See <a class="reference internal" href="#kombu.connection.ConnectionPool" title="kombu.connection.ConnectionPool"><tt class="xref py py-class docutils literal"><span class="pre">ConnectionPool</span></tt></a>.</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><strong>limit</strong> &#8211; Maximum number of active connections.
Default is no limit.</li>
<li><strong>preload</strong> &#8211; Number of connections to preload
when the pool is created.  Default is 0.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><em>Example usage</em>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">pool</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="n">Pool</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c1</span> <span class="o">=</span> <span class="n">pool</span><span class="o">.</span><span class="n">acquire</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c2</span> <span class="o">=</span> <span class="n">pool</span><span class="o">.</span><span class="n">acquire</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c3</span> <span class="o">=</span> <span class="n">pool</span><span class="o">.</span><span class="n">acquire</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c1</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c3</span> <span class="o">=</span> <span class="n">pool</span><span class="o">.</span><span class="n">acquire</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.ChannelPool">
<tt class="descname">ChannelPool</tt><big>(</big><em>limit=None</em>, <em>preload=None</em><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.ChannelPool" title="Permalink to this definition">¶</a></dt>
<dd><p>Pool of channels.</p>
<p>See <a class="reference internal" href="#kombu.connection.ChannelPool" title="kombu.connection.ChannelPool"><tt class="xref py py-class docutils literal"><span class="pre">ChannelPool</span></tt></a>.</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><strong>limit</strong> &#8211; Maximum number of active channels.
Default is no limit.</li>
<li><strong>preload</strong> &#8211; Number of channels to preload
when the pool is created.  Default is 0.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><em>Example usage</em>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">pool</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="n">ChannelPool</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c1</span> <span class="o">=</span> <span class="n">pool</span><span class="o">.</span><span class="n">acquire</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c2</span> <span class="o">=</span> <span class="n">pool</span><span class="o">.</span><span class="n">acquire</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c3</span> <span class="o">=</span> <span class="n">pool</span><span class="o">.</span><span class="n">acquire</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c1</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">c3</span> <span class="o">=</span> <span class="n">pool</span><span class="o">.</span><span class="n">acquire</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.BrokerConnection.SimpleQueue">
<tt class="descname">SimpleQueue</tt><big>(</big><em>name</em>, <em>no_ack=None</em>, <em>queue_opts=None</em>, <em>exchange_opts=None</em>, <em>channel=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.SimpleQueue" title="Permalink to this definition">¶</a></dt>
<dd><p>Create new <a class="reference internal" href="kombu.simple.html#kombu.simple.SimpleQueue" title="kombu.simple.SimpleQueue"><tt class="xref py py-class docutils literal"><span class="pre">SimpleQueue</span></tt></a>, using a channel
from this connection.</p>
<p>If <tt class="docutils literal"><span class="pre">name</span></tt> is a string, a queue and exchange will be automatically
created using that name as the name of the queue and exchange,
also it will be used as the default routing key.</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><strong>name</strong> &#8211; Name of the queue/or a <a class="reference internal" href="kombu.entity.html#kombu.entity.Queue" title="kombu.entity.Queue"><tt class="xref py py-class docutils literal"><span class="pre">Queue</span></tt></a>.</li>
<li><strong>no_ack</strong> &#8211; Disable acknowledgements. Default is false.</li>
<li><strong>queue_opts</strong> &#8211; Additional keyword arguments passed to the
constructor of the automatically created
<a class="reference internal" href="kombu.entity.html#kombu.entity.Queue" title="kombu.entity.Queue"><tt class="xref py py-class docutils literal"><span class="pre">Queue</span></tt></a>.</li>
<li><strong>exchange_opts</strong> &#8211; Additional keyword arguments passed to the
constructor of the automatically created
<a class="reference internal" href="kombu.entity.html#kombu.entity.Exchange" title="kombu.entity.Exchange"><tt class="xref py py-class docutils literal"><span class="pre">Exchange</span></tt></a>.</li>
<li><strong>channel</strong> &#8211; Channel to use. If not specified a new channel
from the current connection will be used. Remember to call
<a class="reference internal" href="kombu.simple.html#kombu.simple.SimpleQueue.close" title="kombu.simple.SimpleQueue.close"><tt class="xref py py-meth docutils literal"><span class="pre">close()</span></tt></a> when done with the
object.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="last method">
<dt id="kombu.connection.BrokerConnection.SimpleBuffer">
<tt class="descname">SimpleBuffer</tt><big>(</big><em>name</em>, <em>no_ack=None</em>, <em>queue_opts=None</em>, <em>exchange_opts=None</em>, <em>channel=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#kombu.connection.BrokerConnection.SimpleBuffer" title="Permalink to this definition">¶</a></dt>
<dd><p>Create new <a class="reference internal" href="kombu.simple.html#kombu.simple.SimpleQueue" title="kombu.simple.SimpleQueue"><tt class="xref py py-class docutils literal"><span class="pre">SimpleQueue</span></tt></a> using a channel
from this connection.</p>
<p>Same as <a class="reference internal" href="#kombu.connection.BrokerConnection.SimpleQueue" title="kombu.connection.BrokerConnection.SimpleQueue"><tt class="xref py py-meth docutils literal"><span class="pre">SimpleQueue()</span></tt></a>, but configured with buffering
semantics. The resulting queue and exchange will not be durable, also
auto delete is enabled. Messages will be transient (not persistent),
and acknowledgements are disabled (<tt class="docutils literal"><span class="pre">no_ack</span></tt>).</p>
</dd></dl>

</div>
</dd></dl>

</div>
<div class="section" id="pools">
<h2><a class="toc-backref" href="#id2">Pools</a><a class="headerlink" href="#pools" title="Permalink to this headline">¶</a></h2>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last">The shortcut methods <a class="reference internal" href="#kombu.connection.BrokerConnection.Pool" title="kombu.connection.BrokerConnection.Pool"><tt class="xref py py-meth docutils literal"><span class="pre">BrokerConnection.Pool()</span></tt></a> and
<a class="reference internal" href="#kombu.connection.BrokerConnection.ChannelPool" title="kombu.connection.BrokerConnection.ChannelPool"><tt class="xref py py-meth docutils literal"><span class="pre">BrokerConnection.ChannelPool()</span></tt></a> is the recommended way
to instantiate these classes.</p>
</div>
<dl class="class">
<dt id="kombu.connection.ConnectionPool">
<em class="property">class </em><tt class="descclassname">kombu.connection.</tt><tt class="descname">ConnectionPool</tt><big>(</big><em>connection</em>, <em>limit=None</em>, <em>preload=None</em><big>)</big><a class="headerlink" href="#kombu.connection.ConnectionPool" title="Permalink to this definition">¶</a></dt>
<dd><dl class="attribute">
<dt id="kombu.connection.ConnectionPool.LimitExceeded">
<tt class="descname">LimitExceeded</tt><a class="headerlink" href="#kombu.connection.ConnectionPool.LimitExceeded" title="Permalink to this definition">¶</a></dt>
<dd><p>Maximum number of simultaneous connections exceeded.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.ConnectionPool.acquire">
<tt class="descname">acquire</tt><big>(</big><em>block=False</em>, <em>timeout=None</em><big>)</big><a class="headerlink" href="#kombu.connection.ConnectionPool.acquire" title="Permalink to this definition">¶</a></dt>
<dd><p>Acquire resource.</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 simple">
<li><strong>block</strong> &#8211; If the limit is exceeded,
block until there is an available item.</li>
<li><strong>timeout</strong> &#8211; Timeout to wait
if <tt class="docutils literal"><span class="pre">block</span></tt> is true. Default is <tt class="xref py py-const xref docutils literal"><span class="pre">None</span></tt> (forever).</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name" colspan="2">Raises LimitExceeded:</th></tr>
<tr><td>&nbsp;</td><td class="field-body"><p class="first last">if block is false
and the limit has been exceeded.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.ConnectionPool.release">
<tt class="descname">release</tt><big>(</big><em>resource</em><big>)</big><a class="headerlink" href="#kombu.connection.ConnectionPool.release" title="Permalink to this definition">¶</a></dt>
<dd><p>Release resource so it can be used by another thread.</p>
<p>The caller is responsible for discarding the object,
and to never use the resource again.  A new resource must
be acquired if so needed.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="kombu.connection.ChannelPool">
<em class="property">class </em><tt class="descclassname">kombu.connection.</tt><tt class="descname">ChannelPool</tt><big>(</big><em>connection</em>, <em>limit=None</em>, <em>preload=None</em><big>)</big><a class="headerlink" href="#kombu.connection.ChannelPool" title="Permalink to this definition">¶</a></dt>
<dd><dl class="attribute">
<dt id="kombu.connection.ChannelPool.LimitExceeded">
<tt class="descname">LimitExceeded</tt><a class="headerlink" href="#kombu.connection.ChannelPool.LimitExceeded" title="Permalink to this definition">¶</a></dt>
<dd><p>Maximum number of simultaenous channels exceeded.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.ChannelPool.acquire">
<tt class="descname">acquire</tt><big>(</big><em>block=False</em>, <em>timeout=None</em><big>)</big><a class="headerlink" href="#kombu.connection.ChannelPool.acquire" title="Permalink to this definition">¶</a></dt>
<dd><p>Acquire resource.</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 simple">
<li><strong>block</strong> &#8211; If the limit is exceeded,
block until there is an available item.</li>
<li><strong>timeout</strong> &#8211; Timeout to wait
if <tt class="docutils literal"><span class="pre">block</span></tt> is true. Default is <tt class="xref py py-const xref docutils literal"><span class="pre">None</span></tt> (forever).</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name" colspan="2">Raises LimitExceeded:</th></tr>
<tr><td>&nbsp;</td><td class="field-body"><p class="first last">if block is false
and the limit has been exceeded.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="kombu.connection.ChannelPool.release">
<tt class="descname">release</tt><big>(</big><em>resource</em><big>)</big><a class="headerlink" href="#kombu.connection.ChannelPool.release" title="Permalink to this definition">¶</a></dt>
<dd><p>Release resource so it can be used by another thread.</p>
<p>The caller is responsible for discarding the object,
and to never use the resource again.  A new resource must
be acquired if so needed.</p>
</dd></dl>

</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="#">kombu.connection</a><ul>
<li><a class="reference internal" href="#connection">Connection</a></li>
<li><a class="reference internal" href="#pools">Pools</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="index.html"
                        title="previous chapter">API Reference</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="kombu.simple.html"
                        title="next chapter">kombu.simple</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../sources/reference/kombu.connection.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="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="kombu.simple.html" title="kombu.simple"
             >next</a> |</li>
        <li class="right" >
          <a href="index.html" title="API Reference"
             >previous</a> |</li>
        <li><a href="../index.html">Kombu v1.0.6 documentation</a> &raquo;</li>
          <li><a href="index.html" >API Reference</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2011, Ask Solem.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.4.
    </div>
  </body>
</html>