-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncio signal handlers don't work on Windows #108
Comments
This appears to be the most successful way of handling interrupts while in an event loop. I have it set in my windows Sanic app to issue the call back once per second to process the interrupts, and its working pretty well. The "fix" that's supposed to be in 3.5 (python/asyncio#191) doesn't work for me |
Windows signal handling in general is a mess. If you just want to catch CTRL+C, you might want to run the loop in a thread and keep the main thread available for an interrupt. This gets messy though. If you're sending signals from other (non parent/child) processes (ex: running using Pretty much all signal handling I'm personally doing on Windows with asyncio involves either threads and/or daughter processes, which eventually call a separate |
Until uvloop supports windows and signals aren't all wonky on windows we don't plan to add windows support! |
In 2019 this is still broken and the current situation is quite unacceptable. I agree that fixing it is very hard, in particular in the multi-worker mode. Having a single worker crash reliably on Ctrl+C would be a big improvement already. The Sanic trio branch terminates cleanly on Ctrl+C in single and multiple worker modes, which shouldn't be surprising considering that Trio's author wrote this. |
Consumes a lot of time, changing directory and running this all over again in windows cmd. Still an issue |
#1808 which is included in 20.03 should already fix this. Which Sanic version are you using? I've also noticed that some IDEs cannot send Ctrl+C properly. Can't investigate further at this time but it would be good to properly triage this if further changes are required. |
Thank you so much @Tronic! Had been looking everywhere for a solution, didn't know a minor update would suffice. |
Sanic attempts to register signal handlers here:
https://github.com/channelcat/sanic/blob/master/sanic/server.py#L227
But using the asyncio event loop (as is the fallback when uvloop can't be imported) does not implement signal handlers. See https://docs.python.org/3/library/asyncio-eventloops.html#windows where it states this, and the code at https://github.com/python/asyncio/blob/master/asyncio/events.py#L480
Commenting out the signal lines in sanic allows sanic to run on windows (yay) but then you can't Ctrl-C out of it, you must kill the python process
The text was updated successfully, but these errors were encountered: