Skip to content

Commit

Permalink
refactor sigint onfini
Browse files Browse the repository at this point in the history
  • Loading branch information
vEpiphyte committed Dec 26, 2024
1 parent 90ba98d commit 1ddc714
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion synapse/lib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,11 @@ def sigint():
self.loop.add_signal_handler(signal.SIGINT, sigint)

def onfini():
self.loop.remove_signal_handler(signal.SIGINT)
# N.B. This is reaches into some loop / handle internals but
# prevents us from removing a handler that overwrote our own.
hndl = self.loop._signal_handlers.get(signal.SIGINT, None) # type: asyncio.Handle
if hndl is not None and hndl._callback is sigint:
self.loop.remove_signal_handler(signal.SIGINT)

self.onfini(onfini)

Expand Down

0 comments on commit 1ddc714

Please sign in to comment.