You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an app that starts a pysysttray and then the uvicorn server in async tasks. I have issues programmatically shutting down when in a pyinstaller app without a console.
Only signal.SIGTERM works without a console but it won't call the lifespan callback. It ends the process with no change to end current running tasks.
If I run in a console and ctl+c it won't properly shut down pysystray task until I ctl+c a few times. I believe this is causing issues with an MSI installer closing the app properly.
In the app. If I launch pysystray from in the lifespan callback it still won't shutdown correctly with ctl+c. Only SIGTERM terminates everything but not graceful.
@contextlib.asynccontextmanager
async def lifespan(app : Starlette):
logger.debug("Startup")
try:
yield
tasks = [t for t in asyncio.all_tasks() if t is not asyncio.current_task()]
[task.cancel() for task in tasks]
logger.debug("Canceling outstanding tasks")
await asyncio.gather(*tasks)
logger.info("Shutting down")
loop.stop()
except asyncio.exceptions.CancelledError as e:
logger.debug("Cancelled")
finally:
""""""
A callback from pysystray to end the process. Won't run lifespan
def on_exit(self) -> None:
if sys.platform == 'darwin':
sig = signal.SIGKILL
else:
sig = signal.SIGTERM
#sig = signal.CTRL_BREAK_EVENT
os.kill(os.getpid(), sig)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have an app that starts a pysysttray and then the uvicorn server in async tasks. I have issues programmatically shutting down when in a pyinstaller app without a console.
Only signal.SIGTERM works without a console but it won't call the lifespan callback. It ends the process with no change to end current running tasks.
If I run in a console and ctl+c it won't properly shut down pysystray task until I ctl+c a few times. I believe this is causing issues with an MSI installer closing the app properly.
Maybe I am launching the app incorrectly.
In the app. If I launch pysystray from in the lifespan callback it still won't shutdown correctly with ctl+c. Only SIGTERM terminates everything but not graceful.
A callback from pysystray to end the process. Won't run lifespan
Beta Was this translation helpful? Give feedback.
All reactions