Skip to content

Commit

Permalink
Catch KeyboardInterrupt instead of signal.signal
Browse files Browse the repository at this point in the history
  • Loading branch information
nocarryr committed Mar 30, 2018
1 parent 7db47aa commit 23a5d9d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions vidhubcontrol/runserver.py
Expand Up @@ -98,14 +98,14 @@ async def run(loop, opts):
config, interfaces = await start(loop, opts)
if sys.platform == 'win32':
async def wakeup():
if config.running.is_set():
await asyncio.sleep(.1)
await wakeup()
signal.signal(signal.SIGINT, partial(on_sigint, config, interfaces))
wakup_fut = asyncio.ensure_future(wakeup())
try:
while config.running.is_set():
await asyncio.sleep(.1)
except KeyboardInterrupt:
await stop(config, interfaces)
await config.stopped.wait()
logger.info('ready')
await config.stopped.wait()
await wakeup_fut
await wakeup()
else:
for sig in [signal.SIGINT, signal.SIGTERM]:
loop.add_signal_handler(sig, on_sigint, config, interfaces)
Expand Down

0 comments on commit 23a5d9d

Please sign in to comment.