Browse Source

Respond to ctrl-c exits

unifiedWindowUI
Luke Murphy 4 years ago
parent
commit
a651c3fad9
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 10
      dropship.py

10
dropship.py

@ -5,6 +5,7 @@ import logging
import os import os
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from signal import SIGINT, SIGTERM
import asyncio_glib import asyncio_glib
import gi import gi
@ -142,13 +143,18 @@ class DropShip:
async def main(): async def main():
"""The application entrypoint.""" """The application entrypoint."""
try:
dropship = DropShip() dropship = DropShip()
await dropship._running await dropship._running
except asyncio.CancelledError:
pass
if __name__ == "__main__": if __name__ == "__main__":
try: try:
# TODO(decentral1se): also handle Ctrl-C escape from terminal main_task = asyncio.ensure_future(main())
loop.run_until_complete(main()) loop.add_signal_handler(SIGINT, main_task.cancel)
loop.add_signal_handler(SIGTERM, main_task.cancel)
loop.run_until_complete(main_task)
finally: finally:
loop.close() loop.close()

Loading…
Cancel
Save