aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-09-14 16:17:41 +0200
committerAnton Khirnov <anton@khirnov.net>2022-09-14 16:17:41 +0200
commit126673ad0d0861e7347391ad9f8d23a1b1e28bcb (patch)
treebad9c7434143f454fa85a9b92a047425d113c519
parent777eb97d8ed42f4c7432fc8ee516e4704a9989e8 (diff)
Split exception handling for reading state and running the server.
-rwxr-xr-xfshare.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/fshare.py b/fshare.py
index e1bc684..85aae01 100755
--- a/fshare.py
+++ b/fshare.py
@@ -397,14 +397,15 @@ with contextlib.ExitStack() as stack:
try:
# read the state file
state = PersistentState(state_dir_fd, logger)
+ except StateCorruptError:
+ logger.error('Corrupted state file')
+ sys.exit(1)
+ try:
# launch the server
server = FShareServer((args.address, args.port), args.ipv4, args.ipv6,
state, args.data_dir, logger)
server.serve_forever()
- except StateCorruptError:
- logger.error('Corrupted state file')
- sys.exit(1)
except KeyboardInterrupt:
logger.info('Interrupted, exiting')
sys.exit(0)