merge_machine/abstract_project.py
def read_config_data(self, module_name, file_name):
        '''Read a json file with retry logic if a file is locked (empty dict 
        if file is not found). If the file doesn't exist, return an empty dict.
        '''
        NUM_RETRY = 10
        RETRY_INTERVAL = 0.1

        file_path = self.path_to(module_name=module_name, 
                                 file_name=file_name)
        if os.path.isfile(file_path):
            for _ in range(NUM_RETRY):
                try:
                    with open(file_path, 'r') as f:
                        # Lock file
                        fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
                        # Read
                        config = json.loads(f.read())
                        # Unlock file
                        fcntl.flock(f, fcntl.LOCK_UN)
                        break
                except BlockingIOError:
                    time.sleep(RETRY_INTERVAL)
            else:
                raise BlockingIOError('{0} is un-readable because '.format(file_path) \
                            + 'it was locked for writing for by another process')
                
        else: 
            config = dict()
        return config
Read a json file with retry logic if a file is locked (empty dict 
        if file is not found). If the file doesn't exist, return an empty dict.
        
Read a json file with retry logic if a file is locked (empty dict
if file is not found). If the file doesn't exist, return an empty dict.
Read a json file with retry logic if a file is locked ( empty dict if file is not found ) . If the file doesn ' t exist return an empty dict .
def read_config_data(self, module_name, file_name):
        NUM_RETRY = 10
        RETRY_INTERVAL = 0.1
        file_path = self.path_to(module_name=module_name, 
                                 file_name=file_name)
        if os.path.isfile(file_path):
            for _ in range(NUM_RETRY):
                try:
                    with open(file_path, 'r') as f:
                        fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
                        config = json.loads(f.read())
                        fcntl.flock(f, fcntl.LOCK_UN)
                        break
                except BlockingIOError:
                    time.sleep(RETRY_INTERVAL)
            else:
                raise BlockingIOError('{0} is un-readable because '.format(file_path) \
                            + 'it was locked for writing for by another process')
        else: 
            config = dict()
        return config
def read_config_data ( self , module_name , file_name ) : NUM_RETRY = 10 RETRY_INTERVAL = 0.1 file_path = self . path_to ( module_name = module_name , file_name = file_name ) if os . path . isfile ( file_path ) : for _ in range ( NUM_RETRY ) : try : with open ( file_path , 'r' ) as f : fcntl . flock ( f , fcntl . LOCK_EX | fcntl . LOCK_NB ) config = json . loads ( f . read ( ) ) fcntl . flock ( f , fcntl . LOCK_UN ) break except BlockingIOError : time . sleep ( RETRY_INTERVAL ) else : raise BlockingIOError ( '{0} is un-readable because ' . format ( file_path ) + 'it was locked for writing for by another process' ) else : config = dict ( ) return config
Read a json file with retry logic if a file is locked (empty dict
if file is not found).
Read a json file with retry logic if a file is locked ( empty dict if file is not found ) .
'''Read a json file with retry logic if a file is locked (empty dict 
        if file is not found). If the file doesn't exist, return an empty dict.
        ''' # Lock file # Read # Unlock file
self
module_name
file_name