aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfshare.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/fshare.py b/fshare.py
index 6bf4f0c..5e48e94 100755
--- a/fshare.py
+++ b/fshare.py
@@ -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)