Add `.cancel()` log around `_async_main()` KBI-exit

qt_w_graceful_SIGINT
Tyler Goodlet 2025-09-29 15:16:43 -04:00
parent f2ae3b0e2e
commit 4398481591
3 changed files with 17 additions and 4 deletions

View File

@ -181,7 +181,14 @@ async def _async_main(
):
# remove startup status text
starting_done()
try:
await trio.sleep_forever()
except KeyboardInterrupt as _kbi:
log.cancel(
f'User canceled Qt app.\n'
f'{_kbi!r}'
)
raise _kbi
def _main(

View File

@ -1,5 +1,5 @@
# piker: trading gear for hackers
# Copyright (C) Tyler Goodlet (in stewardship for piker0)
# Copyright (C) Tyler Goodlet (in stewardship for pikers)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by

View File

@ -217,8 +217,14 @@ class MainWindow(QMainWindow):
'''Cancel the root actor asap.
'''
# raising KBI seems to get intercepted by by Qt so just use the system.
os.kill(os.getpid(), signal.SIGINT)
# raising a KBI seems to get intercepted by Qt, soo just use OS ??
# TODO XXX! seems to sometimes cause Qt core dumps if you
# cancel during chart bootup..?
# -[ ] find a better/more-correct cancellation API in Qt?
os.kill(
os.getpid(),
signal.SIGINT,
)
@property
def status_bar(self) -> QStatusBar: