Comments (7)
#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.
from sanic.
This appears to be the most successful way of handling interrupts while in an event loop.
http://stackoverflow.com/a/24775107/375344
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
from sanic.
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 pythonw.exe
and then interacting from a different console), be careful. Without serious effort, all signals sent this way result in insta-death with no cleanup. There's a very small discussion (written by yours truly) of the mess here as well as a workaround strategy (conveniently packaged with the library that the page is documenting).
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 stop_threadsafe
method, which then starts the shutdown process. It's roundabout, but reliable.
from sanic.
Until uvloop supports windows and signals aren't all wonky on windows we don't plan to add windows support!
from sanic.
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.
from sanic.
In 2019 this is still broken and the current situation is quite unacceptable.
Consumes a lot of time, changing directory and running this all over again in windows cmd. Still an issue
from sanic.
Thank you so much @Tronic! Had been looking everywhere for a solution, didn't know a minor update would suffice.
from sanic.
Related Issues (20)
- DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14 HOT 1
- CLI: Terminal becomes no-echo if not entering REPL mode or exiting without Ctrl+D HOT 3
- Trusted proxies HOT 2
- Sanic stops working after trying to open a WS connection HOT 1
- How can I use the Response streaming technique in a POST method? HOT 2
- Shutdown never finishes when background tasks are cancelled but need some time to finish
- EOFError in Server Manager HOT 2
- Start-up exception HOT 1
- openapi json exception
- The RESTful API has redundant path parameters HOT 1
- Response streaming produces [ERROR] Invalid response type None (need HTTPResponse)
- Unexpected behavior with bp.middleware() using classes HOT 2
- δΈδΈͺζ±ε© HOT 1
- "body not consumed" error on GET request with content-length=0 HOT 1
- mypy error type for async get function in HTTPMethodView HOT 2
- Unexpected behaviour with REQUEST_MAX_HEADER_SIZE HOT 1
- Unexpected behavior when using blueprint groups and app.url_for HOT 1
- How to avoid abort when the code throw an Exception HOT 1
- Sanic drops part of HTTP response data HOT 7
- REQUEST_TIMEOUT & RESPONSE_TIMEOUT not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sanic.