Hi Ritesh,
you can have two functions that returns a Deferred, each consuming
from a different queue and build a DeferredList with those two
Deferreds. For example:
@defer.inlineCallbacks
def consume(consumerTag):
queue = yield conn.queue(consumerTag)
while True:
msg = yield queue.get()
doSomething(msg)
if msg is STOP_TOKEN: # STOP_TOKEN is something the producer
may send to stop the consumer
break
@defer.inlineCallbacks
def myFunc():
d1 = consume("consumerTag1")
d2 = consume("consumerTag2")
dl = DeferredList([d1, d2], fireOnOneCallback=True)
yield dl
print "Finished"
the key is in fireOnOneCallback=True, this way when any of the two
functions finish, the Deferred will be fired and the code flow will
continue.
Cheers.
_______________________________________________
Mailing list: https://launchpad.net/~txamqp-user
Post to : [email protected]
Unsubscribe : https://launchpad.net/~txamqp-user
More help : https://help.launchpad.net/ListHelp