Mike,
I'll take a stab at this, and let you know how we're doing it. I can't say if this is right per se, but it's how I've decided to tackle it.
Basically, we have some processes that do some IO bound operations, and we instruct those processes to do their thing via MQ.
So from the standpoint of async, we grab the messages from the queue, once we get one, we spin off the thread with the function that handles the message, all the while maintaining the heartbeat to the MQ server. We've eschewed the examples where the eventloop is involved, because it doesn' t seem to meet our needs. Then rinse/repeat. The code we're using here is far more complex, but I think this should give you the gist of what we're trying to accomplish.
YMMV
Sample Code:
with Connection(mq_connection_string, heartbeat=10) as connection:
exchange = Exchange(mq_exchange_name, type=mq_exchange_type)(connection)
exchange.declare()
channel = connection.channel()
queue = Queue(name=mq_queue_name, routing_key=mq_routing_key, exchange=exchange)(connection)
bound_queue = queue(channel)
bound_queue.declare()
# perhaps something here to stop processing, like a flag/counter/timer
while true:
msg = bound_queue.get()
if msg is not None:
#kwargs here needs set so that handle_message is getting the proper arguments.
my_thread = threading.Thread(target=handle_message, kwargs=kwargs)
my_thread.daemon = true
my_thread.start()
connection.heartbeat_check(1)
time.sleep(1)
-Bob