#NEWLINE# @ classmethod #NEWLINE# def loop_communication( cls ) : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# while ( not cls . is_connected ) : #NEWLINE# #INDENT# time . sleep ( 1 ) #NEWLINE# #UNINDENT# send_packet = None #NEWLINE# try : #NEWLINE# #INDENT# send_packet = cls . outgoing_queue . popleft ( ) #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# time . sleep ( 1 ) #NEWLINE# pass #NEWLINE# #UNINDENT# if cls : #NEWLINE# #INDENT# ( bytes_sent , err ) = cls . socket_send ( send_packet ) #NEWLINE# if bytes_sent : #NEWLINE# #INDENT# if ( not cls . wait_for_response ( send_packet ) ) : #NEWLINE# #INDENT# out ( 'Retrying waiting for response:' ) #NEWLINE# if ( not cls . wait_for_response ( send_packet ) ) : #NEWLINE# #INDENT# out ( 'Failure to get response. Reconnecting...' ) #NEWLINE# cls . reconnect ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# cls . is_connected = False #NEWLINE# out ( 'Failure to send command. Reconnecting...' ) #NEWLINE# cls . reconnect ( )