MCPcopy Create free account
hub / github.com/certbot/certbot / _handle_lock

Function _handle_lock

certbot/src/certbot/tests/util.py:400–416  ·  view source on GitHub ↗

Acquire a file lock on given path, then wait to release it. This worker is coordinated using events to signal when the lock should be acquired and released. :param multiprocessing.Event event_in: event object to signal when to release the lock :param multiprocessing.Event event_out:

(event_in: synchronize.Event, event_out: synchronize.Event, path: str)

Source from the content-addressed store, hash-verified

398
399
400def _handle_lock(event_in: synchronize.Event, event_out: synchronize.Event, path: str) -> None:
401 """
402 Acquire a file lock on given path, then wait to release it. This worker is coordinated
403 using events to signal when the lock should be acquired and released.
404 :param multiprocessing.Event event_in: event object to signal when to release the lock
405 :param multiprocessing.Event event_out: event object to signal when the lock is acquired
406 :param path: the path to lock
407 """
408 if os.path.isdir(path):
409 my_lock = lock.lock_dir(path)
410 else:
411 my_lock = lock.LockFile(path)
412 try:
413 event_out.set()
414 assert event_in.wait(timeout=20), 'Timeout while waiting to release the lock.'
415 finally:
416 my_lock.release()
417
418
419def lock_and_call(callback: Callable[[], Any], path_to_lock: str) -> None:

Callers

nothing calls this directly

Calls 1

releaseMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…