Respond to ctrl-c exits
This commit is contained in:
parent
41634265f0
commit
a651c3fad9
14
dropship.py
14
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."""
|
||||||
dropship = DropShip()
|
try:
|
||||||
await dropship._running
|
dropship = DropShip()
|
||||||
|
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…
Reference in New Issue
Block a user