Skip to content

Commit

Permalink
Fix issue with signal.siginterrupt not being available in Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kspaceKelvin committed Oct 2, 2024
1 parent 86ff610 commit daad359
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ def serve(self):
self.socket.listen(0)

while True:
signal.siginterrupt(signal.SIGTERM, True)
signal.siginterrupt(signal.SIGINT, True)

try:
signal.siginterrupt(signal.SIGTERM, True)
signal.siginterrupt(signal.SIGINT, True)
except AttributeError:
# signal.siginterrupt is not available in Windows
pass

sock, (remote_addr, remote_port) = self.socket.accept()

logging.info("Accepting connection from: %s:%d", remote_addr, remote_port)
Expand Down

0 comments on commit daad359

Please sign in to comment.