in uamqp/client.py [0:0]
def receive_messages(self, on_message_received):
"""Receive messages. This function will run indefinitely, until the client
closes either via timeout, error or forced interruption (e.g. keyboard interrupt).
If the receive client is configured with `auto_complete=True` then the messages that
have not been settled on completion of the provided callback will automatically be
accepted provided it has not expired. If an error occurs or the message has expired
it will be released. Alternatively if `auto_complete=False`, each message will need
to be explicitly settled during the callback, otherwise it will be released.
:param on_message_received: A callback to process messages as they arrive from the
service. It takes a single argument, a ~uamqp.message.Message object.
:type on_message_received: callable[~uamqp.message.Message]
"""
self._streaming_receive = True
self.open()
self._message_received_callback = on_message_received
self._timeout_reached = False
self._last_activity_timestamp = None
receiving = True
try:
while receiving and not self._timeout_reached:
receiving = self.do_work()
receiving = False
except:
receiving = False
raise
finally:
self._streaming_receive = False
if not receiving and self._shutdown_after_timeout:
self.close()