Skip to content

Commit

Permalink
Don't add signal handler multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed Dec 26, 2018
1 parent 37442ba commit bbc3d9e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions simpervisor/atexitasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
signal_handler_set = False

def add_handler(handler):
global signal_handler_set
if not signal_handler_set:
loop = asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGINT, _handle_signal, signal.SIGINT)
loop.add_signal_handler(signal.SIGTERM, _handle_signal, signal.SIGTERM)
signal_handler_set = True
_handlers.append(handler)

def remove_handler(handler):
Expand Down

0 comments on commit bbc3d9e

Please sign in to comment.