Hi Ale

On 11/16/09, Ale <peralta.alejan...@gmail.com> wrote:
>> Yeah :-), I was thinking more of breaking the consumer loop because
>> I'm quiting my program and I want to end cleanly. Maybe using a global
>> boolean variable? Sending a STOP message from the consumer to
>> terminate that same process doesn't look right.

IMHO, a cleaner approach is to do:

STOP_TOKEN = object()

def consumer_fanout(conn, chan, queue):

    while True:
        msg = yield queue.get()
        if msg is STOP_TOKEN:

        print '[FANOUT] Received: ' + msg.content.body + ' from
channel #' + str(chan.id)

    yield chan.basic_cancel("testtag_fanout")

and then, when the user quits the application, put the STOP_TOKEN
object in the queue:


remember that when you call queue() on a channel instance, you get an
instance of DeferredQueue
so you're free to put whatever you want in it without having to send
anything through the network :-)


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

Reply via email to