#NEWLINE# def run( self , connection , wrapped_callback ) : #NEWLINE# #INDENT# '\n        Run the wrapped_callback in a protective covering of retries and error handling.\n\n        :param connection: Connection to messaging service\n        :type connection: kombu.connection.Connection\n\n        :param wrapped_callback: Callback that will be wrapped by all the fine handling in this\n                                 method. Expected signature of callback -\n                                 ``def func(connection, channel)``\n        ' #NEWLINE# should_stop = False #NEWLINE# channel = None #NEWLINE# while ( not should_stop ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# channel = connection . channel ( ) #NEWLINE# wrapped_callback ( connection = connection , channel = channel ) #NEWLINE# should_stop = True #NEWLINE# #UNINDENT# except ( connection . connection_errors + connection . channel_errors ) as e : #NEWLINE# #INDENT# self . _logger . exception ( ( 'Connection or channel error identified: %s.' % str ( e ) ) ) #NEWLINE# ( should_stop , wait ) = self . _retry_context . test_should_stop ( ) #NEWLINE# channel = None #NEWLINE# if should_stop : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# eventlet . sleep ( wait ) #NEWLINE# connection . close ( ) #NEWLINE# connection . ensure_connection ( ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# self . _logger . exception ( 'Connections to rabbitmq cannot be re-established: %s' , e . message ) #NEWLINE# raise #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# if ( should_stop and channel ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# channel . close ( ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# self . _logger . warning ( 'Error closing channel.' , exc_info = True )