#NEWLINE# def _defer_command( self , cmd , args , result_channel , error_value = None ) : #NEWLINE# #INDENT# def _read_result( ) : #NEWLINE# #INDENT# timeout = Timeout ( self . _read_timeout , Timeout ) #NEWLINE# timeout . start ( ) #NEWLINE# try : #NEWLINE# #INDENT# result = self . _read_result ( cmd ) #NEWLINE# result_channel . put ( result ) #NEWLINE# #UNINDENT# except Timeout : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# self . log . exception ( 'read error in defer_command' ) #NEWLINE# result_channel . put ( ( MemcacheResult . ERROR , error_value ) ) #NEWLINE# self . log . warn ( 'Error communicating with Memcache %s, disconnecting' , self . _address ) #NEWLINE# self . disconnect ( ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# timeout . cancel ( ) #NEWLINE# #UNINDENT# #UNINDENT# def _write_command( ) : #NEWLINE# #INDENT# timeout = Timeout ( self . _write_timeout , Timeout ) #NEWLINE# timeout . start ( ) #NEWLINE# try : #NEWLINE# #INDENT# if ( not self . is_connected ( ) ) : #NEWLINE# #INDENT# self . connect ( ) #NEWLINE# #UNINDENT# self . _write_command ( cmd , args , True ) #NEWLINE# self . _read_queue . defer ( _read_result ) #NEWLINE# #UNINDENT# except Timeout : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# result_channel . put ( ( MemcacheResult . ERROR , error_value ) ) #NEWLINE# self . log . warn ( 'Error communicating with Memcache %s, disconnecting' , self . _address ) #NEWLINE# self . disconnect ( ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# timeout . cancel ( ) #NEWLINE# #UNINDENT# #UNINDENT# self . _write_queue . defer ( _write_command )