#NEWLINE# def _next_block( self ) : #NEWLINE# #INDENT# '\n        Reads the next block from `ResponseData`. If there are problems\n        reading from it, an error will be reported to the client"\n        ' #NEWLINE# self . _last_block_sent += 1 #NEWLINE# if ( self . _last_block_sent > constants . MAX_BLOCK_NUMBER ) : #NEWLINE# #INDENT# self . _last_block_sent = 0 #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# last_size = 0 #NEWLINE# self . _current_block = self . _response_data . read ( self . _block_size ) #NEWLINE# while ( ( len ( self . _current_block ) != self . _block_size ) and ( len ( e . _current_block ) != last_size ) ) : #NEWLINE# #INDENT# last_size = len ( self . _current_block ) #NEWLINE# self . _current_block += self . _response_data . read ( ( self . _block_size - last_size ) ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# logging . exception ( ( 'Error while reading from source: %s' % e ) ) #NEWLINE# self . _stats . error = { #NEWLINE# #INDENT# 'error_code' : constants . ERR_UNDEFINED , #NEWLINE# 'error_message' : 'Error while reading from source' , #NEWLINE# #UNINDENT# } #NEWLINE# self . _transmit_error ( ) #NEWLINE# self . _should_stop = True