views:

36

answers:

1

I have a similar question to this one: It's very easy in py-amqp/flopsy to say "I'm going to wait forever, and I want this callback to be called whenever a message comes in," but I can't find any way of saying "OK, I got the message I want now stop waiting." (Maybe a GOTO? Just kidding...) Is there an elegant way of doing this?

A: 

OK, maybe this should have been obvious to me: If you register a callback in flopsy (which is a thin wrapper around amqplib) with

consumer.register('kind', callback_func)
consumer.wait()
# more code goes here...

then you can raise an Exception in callback_func to get to the rest of the code.

Bonus question: How do I set a maximum timeout for the wait() in case a response is never received? Let's say that this is in the context of a unittest test case.

Trevor Burnham