#NEWLINE# def process_forever( self , inhandle , outhandle , timeout = 0.1 ) : #NEWLINE# #INDENT# self . _connect ( ) #NEWLINE# fcntl . fcntl ( inhandle , fcntl . F_SETFL , os . O_NONBLOCK ) #NEWLINE# started = time . time ( ) #NEWLINE# disconnecting = False #NEWLINE# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# messages = inhandle . read ( ) #NEWLINE# #UNINDENT# except IOError : #NEWLINE# #INDENT# messages = None #NEWLINE# #UNINDENT# if messages : #NEWLINE# #INDENT# for message in messages . split ( '(Pdb)' ) : #NEWLINE# #INDENT# stripped = message . strip ( ) #NEWLINE# if stripped : #NEWLINE# #INDENT# logger . debug ( '>> %s' , stripped ) #NEWLINE# self . send_channel_message ( stripped ) #NEWLINE# #UNINDENT# #UNINDENT# self . send_prompt ( ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . reactor . process_once ( timeout ) #NEWLINE# #UNINDENT# except UnicodeDecodeError : #NEWLINE# #INDENT# logger . warning ( 'UnicodeDecodeError raised while processing messages.' ) #NEWLINE# #UNINDENT# while True : #NEWLINE# #INDENT# if self . queue . empty ( ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# message = self . queue . get ( block = False ) #NEWLINE# logger . debug ( '<< %s' , message ) #NEWLINE# outhandle . write ( ( '%s\n' % message ) ) #NEWLINE# outhandle . flush ( ) #NEWLINE# #UNINDENT# if ( ( time . time ( ) > ( messages + self . activation_timeout ) ) and ( not self . activated ) and ( not disconnecting ) ) : #NEWLINE# #INDENT# self . send_channel_message ( [ ( 'No response received within %s seconds; disconnecting due to inactivity.' % self . activation_timeout ) ] , dpaste = False ) #NEWLINE# disconnecting = True #NEWLINE# self . queue . put ( 'c' )