#NEWLINE# def _handle_data( self , msg , args , kwargs ) : #NEWLINE# #INDENT# 'Handles data and returns `True` or `False` if everything is done.' #NEWLINE# stop = False #NEWLINE# try : #NEWLINE# #INDENT# if ( msg == 'DONE' ) : #NEWLINE# #INDENT# stop = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg == 'STORE' ) : #NEWLINE# #INDENT# if ( 'msg' in kwargs ) : #NEWLINE# #INDENT# store_msg = kwargs . pop ( 'msg' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# store_msg = args [ 0 ] #NEWLINE# args = args [ 1 : ] #NEWLINE# #UNINDENT# if ( 'stuff_to_store' in kwargs ) : #NEWLINE# #INDENT# stuff_to_store = kwargs . pop ( 'stuff_to_store' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# stuff_to_store = args [ 0 ] #NEWLINE# args = args [ 1 : ] #NEWLINE# #UNINDENT# trajectory_name = kwargs [ 'trajectory_name' ] #NEWLINE# if ( self . _trajectory_name != trajectory_name ) : #NEWLINE# #INDENT# if self . _storage_service . is_open : #NEWLINE# #INDENT# self . _close_file ( ) #NEWLINE# #UNINDENT# self . _trajectory_name = trajectory_name #NEWLINE# self . _open_file ( ) #NEWLINE# #UNINDENT# self . _storage_service . store ( store_msg , stuff_to_store , * args , ** kwargs ) #NEWLINE# self . _storage_service . store ( pypetconstants . FLUSH , None ) #NEWLINE# self . _check_and_collect_garbage ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise RuntimeError ( ( 'You queued something that was not intended to be queued. I did not understand message `%s`.' % msg ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# self . _logger . exception ( 'ERROR occurred during storing!' ) #NEWLINE# time . sleep ( 0.01 ) #NEWLINE# pass #NEWLINE# #UNINDENT# return stop