Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def lock_file(path, **kwargs):
_locks_lock.acquire()
try:
lock = _locks.get(path)
if lock is None:
lock = _create_lock_file(path)
_locks[path] = lock
finally:
_locks_lock.release()
return _Locker(lock, **kwargs)