Hi Terry On Mon, Nov 16, 2009 at 1:26 AM, Terry Jones <te...@fluidinfo.com> wrote: > @inlineCallbacks > def consumer_fanout(conn, chan, queue, sig): > > done = False > > def _cancel(failure): > # failure.trap(SomeErrorType) > done = True > return chan.basic_cancel("testtag_fanout") > > while not done: > d = queue.get() > d.addErrback(_cancel) > msg = yield d > print '[FANOUT] Received: ' + msg.content.body + ... > > And you might want to use failure.trap in _cancel to make sure you have a > Closed error, supposing you care.
there's probably something I'm missing here, but why are you defining a function and attaching it to an errback if you're already using inlineCallbacks? This looks cleaner to me: @inlineCallbacks def consumer_fanout(conn, chan, queue, sig): done = False while not done: try: msg = yield queue.get() print '[FANOUT] Received: ' + msg.content.body + ... except: # you may replace this with except SomeErrorType done = True yield chan.basic_cancel("testtag_fanout") Cheers. _______________________________________________ Mailing list: https://launchpad.net/~txamqp-user Post to : txamqp-user@lists.launchpad.net Unsubscribe : https://launchpad.net/~txamqp-user More help : https://help.launchpad.net/ListHelp