Exemple #1
0
 def _run_with_process_lock(self, lock_name, functor, *args, **kwargs):
     lock_path = os.path.join(self.backend.lock_path, lock_name)
     with lock_utils.InterProcessLock(lock_path):
         try:
             return functor(*args, **kwargs)
         except exc.TaskFlowException:
             raise
         except Exception as e:
             LOG.exception("Failed running locking file based session")
             # NOTE(harlowja): trap all other errors as storage errors.
             raise exc.StorageError("Storage backend internal error", e)
 def __init__(self, *args, **kwargs):
     test.TestCase.__init__(self, *args, **kwargs)
     # We need to make sure that each test goes through a set of locks
     # to ensure that multiple tests are not modifying the database,
     # dropping it, creating it at the same time. To accomplish this we use
     # a lock that ensures multiple parallel processes can't run at the
     # same time as well as a in-process lock to ensure that multiple
     # threads can't run at the same time.
     lock_path = os.path.join(tempfile.gettempdir(),
                              'taskflow-%s.lock' % (self.LOCK_NAME))
     locks = [
         lock_utils.InterProcessLock(lock_path),
         threading.RLock(),
     ]
     self.big_lock = lock_utils.MultiLock(locks)
Exemple #3
0
 def _path_lock(self, path):
     lockfile = self._join_path(path, 'lock')
     with lock_utils.InterProcessLock(lockfile) as lock:
         with _storagefailure_wrapper():
             yield lock