Merge lp:~therve/txamqp/queue-timeout into lp:txamqp

Proposed by Esteve Fernandez
Status: Merged
Merged at revision: not available
Proposed branch: lp:~therve/txamqp/queue-timeout
Merge into: lp:txamqp
Diff against target: None lines
To merge this branch: bzr merge lp:~therve/txamqp/queue-timeout
Reviewer Review Type Date Requested Status
Esteve Fernandez Approve
Thomas Herve Pending
Review via email: mp+5897@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Esteve Fernandez (esteve) :
review: Approve
lp:~therve/txamqp/queue-timeout updated
14. By Thomas Herve

Parametrize the reactor for easing tests.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/txamqp/queue.py'
2--- src/txamqp/queue.py 2008-10-29 18:31:04 +0000
3+++ src/txamqp/queue.py 2009-04-23 12:04:46 +0000
4@@ -17,7 +17,9 @@
5 self.waiting.remove(deferred)
6 deferred.errback(Empty())
7
8- def _raiseIfClosed(self, result):
9+ def _raiseIfClosed(self, result, call_id):
10+ if call_id is not None:
11+ call_id.cancel()
12 if result == TimeoutDeferredQueue.END:
13 self.put(TimeoutDeferredQueue.END)
14
15@@ -28,10 +30,12 @@
16 def get(self, timeout=None):
17 deferred = DeferredQueue.get(self)
18
19- deferred.addCallback(self._raiseIfClosed)
20-
21+ call_id = None
22 if timeout:
23- deferred.setTimeout(timeout, timeoutFunc=self._timeout)
24+ from twisted.internet import reactor
25+ call_id = reactor.callLater(timeout, self._timeout, deferred)
26+ deferred.addCallback(self._raiseIfClosed, call_id)
27+
28 return deferred
29
30 def close(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: