Skip to content

Commit c4b7b34

Browse files
authored
ignore errors during setting up signal handlers
Windows has limited support for signals so might fail there. This change just makes the failure silent and then only depend on atexit handlers for cleanup
1 parent 52514eb commit c4b7b34

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

dirlock/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@ def handle_sigterm_cleanup(signum, frame):
6868
# normal exit clean up
6969
atexit.register(_clean_locks)
7070

71-
# ctrl+c cleanup
72-
signal.signal(signal.SIGINT, handle_sigint_cleanup)
73-
# sigterm cleanup
74-
signal.signal(signal.SIGTERM, handle_sigterm_cleanup)
71+
try:
72+
# ctrl+c cleanup
73+
signal.signal(signal.SIGINT, handle_sigint_cleanup)
74+
except Exception:
75+
pass
76+
77+
try:
78+
# sigterm cleanup
79+
signal.signal(signal.SIGTERM, handle_sigterm_cleanup)
80+
except Exception:
81+
pass
7582

7683

7784
class DirLock:

0 commit comments

Comments
 (0)