#NEWLINE# def _shutdown_connection( self , force = False ) : #NEWLINE# #INDENT# 'Tell Channel0 and IO to stop if they are not stopped.\n\n        :param force: Force the connection to shutdown without AMQP negotiation\n        :type force: bool\n\n        ' #NEWLINE# self . _heartbeat_checker . stop ( ) #NEWLINE# if ( ( not force ) and ( not self . _io . is_alive ( ) ) ) : #NEWLINE# #INDENT# self . _set_state ( self . CLOSED ) #NEWLINE# LOGGER . debug ( 'Cant shutdown connection, IO is no longer alive' ) #NEWLINE# return #NEWLINE# #UNINDENT# for chan_id in [ chan_id for chan_id in self . _channels if ( not self . _channels [ chan_id ] . closed ) ] : #NEWLINE# #INDENT# if force : #NEWLINE# #INDENT# self . _channels [ chan_id ] . _force_close ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _channels [ chan_id ] . close ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( self . _channel0 . open and ( not self . _events . is_set ( events . CHANNEL0_CLOSED ) ) ) : #NEWLINE# #INDENT# self . _channel0 . close ( ) #NEWLINE# LOGGER . debug ( 'Waiting on channel0 to close' ) #NEWLINE# while ( ( not self . _channel0 . closed ) and self . _io . is_alive ( ) ) : #NEWLINE# #INDENT# LOGGER . debug ( 'Waiting on channel0 to close' ) #NEWLINE# time . sleep ( 0.1 ) #NEWLINE# #UNINDENT# LOGGER . debug ( 'channel0 closed' ) #NEWLINE# #UNINDENT# if ( self . _events . is_set ( events . SOCKET_OPENED ) and ( not self . _events . is_set ( events . SOCKET_CLOSED ) ) ) : #NEWLINE# #INDENT# LOGGER . debug ( 'Requesting IO socket close' ) #NEWLINE# self . _events . set ( events . SOCKET_CLOSE ) #NEWLINE# self . _trigger_write ( ) #NEWLINE# LOGGER . debug ( 'Waiting on socket to close' ) #NEWLINE# self . _events . wait ( events . SOCKET_CLOSED , 0.1 ) #NEWLINE# while self . _io . is_alive ( ) : #NEWLINE# #INDENT# time . sleep ( 0.25 )