#NEWLINE# def basic_consume( self , queue = '' , consumer_tag = '' , no_local = False , no_ack = False , exclusive = False , nowait = False , arguments = None ) : #NEWLINE# #INDENT# 'Start a queue consumer\n\n        This method asks the server to start a "consumer", which is a transient\n        request for messages from a specific queue. Consumers last as long as\n        the channel they were declared on, or until the client cancels them.\n\n        This method will act as an generator, returning messages as they are\n        delivered from the server.\n\n        Example use:\n\n        .. code:: python\n\n            for message in basic_consume(queue_name):\n                print message.body\n                message.ack()\n\n        :param str queue: The queue name to consume from\n        :param str consumer-tag: The consumer tag\n        :param bool no_local: Do not deliver own messages\n        :param bool no_ack: No acknowledgement needed\n        :param bool exclusive: Request exclusive access\n        :param bool nowait: Do not send a reply method\n        :param dict arguments: Arguments for declaration\n\n        ' #NEWLINE# if ( not consumer_tag ) : #NEWLINE# #INDENT# consumer_tag = self . consumer_tag #NEWLINE# #UNINDENT# self . channel . _consumers [ consumer_tag ] = ( self , no_ack ) #NEWLINE# self . _rpc ( spec . Basic . Consume ( 0 , queue , consumer_tag , no_local , no_ack , exclusive , nowait , consumer_tag ) ) #NEWLINE# self . _consuming = True #NEWLINE# try : #NEWLINE# #INDENT# while self . _consuming : #NEWLINE# #INDENT# msg = self . channel . _consume_message ( ) #NEWLINE# if msg : #NEWLINE# #INDENT# ( yield msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . _consuming : #NEWLINE# #INDENT# self . basic_cancel ( consumer_tag ) #NEWLINE# #UNINDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# if self . _consuming : #NEWLINE# #INDENT# self . basic_cancel ( consumer_tag )