Closed GoogleCodeExporter closed 9 years ago
Sorry, but now that I had a night to sleep on it, this isn't really necessary.
I handled it in my wrapper class. I just shimmed the basic_consumer to call my
__deserialize function and that function calls the users call back when it is
finished. i.e.
def start_consuming(self, callback, queue_name=None, consumer_tag='consumer'):
if hasattr(self, 'queue_name') or queue_name:
self.callbacks[consumer_tag] = callback
self.channel.basic_consume(queue=getattr(self, 'queue_name', queue_name),
callback=self.__deserialize,
consumer_tag=consumer_tag)
def __deserialize(self, msg):
'''Do any necessary deserialization necesary, then call the user
requested call back'''
if msg.properties['content_type'] == u'text/yaml':
msg.body = yaml.load(msg.body)
# Now hand the msg object off to the user specified call back
return self.callbacks[msg.delivery_info['consumer_tag']](msg)
Now this is handled by my wrapper class and not the user callback function.
Thanks for the library!
Original comment by dunde...@gmail.com
on 16 Feb 2011 at 4:16
Great, glad you got that to work.
Original comment by barry.pe...@gmail.com
on 28 Mar 2011 at 7:08
Original issue reported on code.google.com by
dunde...@gmail.com
on 15 Feb 2011 at 6:15