merge_machine/linker.py
def labeller_to_json(self, labeller):
        '''Write a Labeller object as a json in the appropriate directory. This
        includes a locking logic to avoid concurrent writes.
        '''
        NUM_RETRY = 10
        RETRY_INTERVAL = 0.1
        
        file_path = self.path_to('es_linker', 'labeller.json')
        
        for _ in range(NUM_RETRY):
            try:
                # Lock File before writing
                with open(file_path, 'a') as f:
                    fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
                
                # Write file
                labeller.to_json(file_path)
                
                # Unlock file
                with open(file_path, 'r') as w:
                    fcntl.flock(w, fcntl.LOCK_UN)
                break
                    
            except BlockingIOError:
                time.sleep(RETRY_INTERVAL)
        else:
            raise BlockingIOError('{0} is un-writable because '.format(file_path) \
                                + 'it was locked for by another process.')
Write a Labeller object as a json in the appropriate directory. This
        includes a locking logic to avoid concurrent writes.
        
Write a Labeller object as a json in the appropriate directory. This
includes a locking logic to avoid concurrent writes.
Write a Labeller object as a json in the appropriate directory . This includes a locking logic to avoid concurrent writes .
def labeller_to_json(self, labeller):
        NUM_RETRY = 10
        RETRY_INTERVAL = 0.1
        file_path = self.path_to('es_linker', 'labeller.json')
        for _ in range(NUM_RETRY):
            try:
                with open(file_path, 'a') as f:
                    fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
                labeller.to_json(file_path)
                with open(file_path, 'r') as w:
                    fcntl.flock(w, fcntl.LOCK_UN)
                break
            except BlockingIOError:
                time.sleep(RETRY_INTERVAL)
        else:
            raise BlockingIOError('{0} is un-writable because '.format(file_path) \
                                + 'it was locked for by another process.')
def labeller_to_json ( self , labeller ) : NUM_RETRY = 10 RETRY_INTERVAL = 0.1 file_path = self . path_to ( 'es_linker' , 'labeller.json' ) for _ in range ( NUM_RETRY ) : try : with open ( file_path , 'a' ) as f : fcntl . flock ( f , fcntl . LOCK_EX | fcntl . LOCK_NB ) labeller . to_json ( file_path ) with open ( file_path , 'r' ) as w : fcntl . flock ( w , fcntl . LOCK_UN ) break except BlockingIOError : time . sleep ( RETRY_INTERVAL ) else : raise BlockingIOError ( '{0} is un-writable because ' . format ( file_path ) + 'it was locked for by another process.' )
Write a Labeller object as a json in the appropriate directory.
Write a Labeller object as a json in the appropriate directory .
'''Write a Labeller object as a json in the appropriate directory. This
        includes a locking logic to avoid concurrent writes.
        ''' # Lock File before writing # Write file # Unlock file
self
labeller