Git Product home page Git Product logo

Comments (7)

Tronic avatar Tronic commented on April 27, 2024 1

#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.

veaviticus avatar veaviticus commented on April 27, 2024

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.

Badg avatar Badg commented on April 27, 2024

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.

seemethere avatar seemethere commented on April 27, 2024

Until uvloop supports windows and signals aren't all wonky on windows we don't plan to add windows support!

from sanic.

Tronic avatar Tronic commented on April 27, 2024

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.

karman1102 avatar karman1102 commented on April 27, 2024

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.

karman1102 avatar karman1102 commented on April 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.