#NEWLINE# def process_answer( self , context , channel , req_event , rep_event , handle_remote_error ) : #NEWLINE# #INDENT# def is_stream_done( rep_event ) : #NEWLINE# #INDENT# return ( rep_event . name == 'STREAM_DONE' ) #NEWLINE# #UNINDENT# channel . on_close_if = is_stream_done #NEWLINE# def iterator( req_event , rep_event ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# while ( rep_event . name == 'STREAM' ) : #NEWLINE# #INDENT# ( yield rep_event . args ) #NEWLINE# rep_event = channel . recv ( ) #NEWLINE# #UNINDENT# if ( rep_event . name == 'ERR' ) : #NEWLINE# #INDENT# exception = handle_remote_error ( rep_event ) #NEWLINE# context . hook_client_after_request ( req_event , rep_event , exception ) #NEWLINE# raise exception #NEWLINE# #UNINDENT# context . hook_client_after_request ( req_event , rep_event ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# channel . close ( ) #NEWLINE# #UNINDENT# #UNINDENT# return iterator ( req_event , is_stream_done )