code: def check_lock(i):
      
      p=i['path']
      uuid=i.get('unlock_uid','')
  
      pl=os.path.join(p, cfg['subdir_ck_ext'], cfg['file_for_lock'])
  
      luid=''
      if os.path.isfile(pl):
         import time
  
         # Read lock file
         try:
            f=open(pl)
            luid=f.readline().strip()
            exp=float(f.readline().strip())
            if exp<0: exp=1
            f.close()
         except Exception as e:
            return {'return':1, 'error':'problem reading lock file'}
  
         # Check if lock has expired
         dt=os.path.getmtime(pl)+exp-time.time()
         if dt<0: 
            # Expired
            if uuid=='' or uuid==luid:
               os.remove(pl)
            else:
               return {'return':32, 'error':'entry lock UID is not matching'}
         else:
            if uuid=='':
               return {'return':32, 'error':'entry is locked'}
            elif uuid!=luid:
               return {'return':32, 'error':'entry is locked with different UID'}
  
      elif uuid!='':
         return {'return':32, 'error':'lock was removed or expired'}
  
      return {'return':0}
docs: Input:  {
                path               - path to be locked
                (unlock_uid)       - UID of the lock to release it
              }
  
      Output: {
                return       - return code =  0, if successful
                                           = 32, lock UID is not matching
                                           >  0, if error
                (error)      - error text if return > 0
              }