diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-09-14 16:13:05 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2022-09-14 16:13:39 +0200 |
commit | 2e5e247801a313603894529d0b44ca40f04d931e (patch) | |
tree | 93651b0716b3070b39afdb122cc867106b053c29 | |
parent | 8ce1ed62c93381f17fea61b207d8eb89a3c4c0d8 (diff) |
Use the exit stack for releasing the state dir lock.
-rwxr-xr-x | fshare.py | 3 |
1 files changed, 1 insertions, 2 deletions
@@ -392,6 +392,7 @@ with contextlib.ExitStack() as stack: except BlockingIOError: logger.error('The state directory is already locked by another process') sys.exit(1) + stack.callback(fcntl.flock, state_dir_fd, fcntl.LOCK_UN) try: # read the state file @@ -404,5 +405,3 @@ with contextlib.ExitStack() as stack: except StateCorruptError: logger.error('Corrupted state file') sys.exit(1) - finally: - fcntl.flock(state_dir_fd, fcntl.LOCK_UN) |