#NEWLINE# def finish_request( self ) : #NEWLINE# #INDENT# if ( self . state == self . STATE_CONNECTED ) : #NEWLINE# #INDENT# self . decoder_pipeline . finish_request ( ) #NEWLINE# self . state = self . STATE_FINISHED #NEWLINE# return #NEWLINE# #UNINDENT# if ( self . state == self . STATE_INITIALIZED ) : #NEWLINE# #INDENT# self . decoder_pipeline . finish_request ( ) #NEWLINE# self . state = self . STATE_FINISHED #NEWLINE# return #NEWLINE# #UNINDENT# if ( self . state != self . STATE_FINISHED ) : #NEWLINE# #INDENT# logger . info ( ( '%s: Master disconnected before decoder reached EOS?' % self . request_id ) ) #NEWLINE# self . state = self . STATE_CANCELLING #NEWLINE# self . decoder_pipeline . cancel ( ) #NEWLINE# counter = 0 #NEWLINE# while ( self . state == self . STATE_CANCELLING ) : #NEWLINE# #INDENT# counter += 1 #NEWLINE# if ( counter > 30 ) : #NEWLINE# #INDENT# logger . info ( ( '%s: Giving up waiting after %d tries' % ( self . request_id , counter ) ) ) #NEWLINE# self . state = self . STATE_FINISHED #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logger . info ( ( '%s: Waiting for EOS from decoder' % self . request_id ) ) #NEWLINE# time . sleep ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# self . decoder_pipeline . finish_request ( ) #NEWLINE# logger . info ( ( '%s: Finished waiting for EOS' % self . request_id ) )