Skip to content
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

Add a SIGKILL to second ctrl+c #2621

Merged
merged 5 commits into from Dec 14, 2022
Merged

Add a SIGKILL to second ctrl+c #2621

merged 5 commits into from Dec 14, 2022

Conversation

ahopkins
Copy link
Member

@ahopkins ahopkins commented Dec 8, 2022

Hitting ctrl+c sends SIGINT to do a graceful shutdown on each worker process. Subsequent ctrl+c currently do nothing.

This PR adds functionality so that the second ctrl+c will send a SIGKILL to the processes for immediate shutdown.

@ahopkins ahopkins requested a review from a team as a code owner December 8, 2022 09:27
@codecov
Copy link

codecov bot commented Dec 8, 2022

Codecov Report

Base: 88.614% // Head: 88.456% // Decreases project coverage by -0.157% ⚠️

Coverage data is based on head (fa92475) compared to base (db39e12).
Patch coverage: 20.000% of modified lines in pull request are covered.

❗ Current head fa92475 differs from pull request most recent head dce6c26. Consider uploading reports for the commit dce6c26 to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##              main     #2621       +/-   ##
=============================================
- Coverage   88.614%   88.456%   -0.158%     
=============================================
  Files           81        81               
  Lines         6684      6636       -48     
  Branches      1142      1130       -12     
=============================================
- Hits          5923      5870       -53     
- Misses         524       527        +3     
- Partials       237       239        +2     
Impacted Files Coverage Δ
sanic/worker/manager.py 89.830% <20.000%> (-2.980%) ⬇️
sanic/server/websockets/impl.py 37.557% <0.000%> (-0.922%) ⬇️
sanic/worker/process.py 88.764% <0.000%> (-0.125%) ⬇️
sanic/worker/inspector.py 98.850% <0.000%> (-0.075%) ⬇️
sanic/request.py 94.486% <0.000%> (-0.042%) ⬇️
sanic/worker/multiplexer.py 100.000% <0.000%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

prryplatypus
prryplatypus previously approved these changes Dec 8, 2022
@Tronic
Copy link
Member

Tronic commented Dec 8, 2022

Did you check how this behaves on Windows? IIRC, terminate already works the same as kill, and also KeyboardInterrupt may be received by any of the processes. Also, might consider only handling second Ctrl-C after a slight delay, as it is quite easy to accidentally hit it twice, but this is also not of that much importance (I don't mind if there is no delay required).

@ahopkins
Copy link
Member Author

ahopkins commented Dec 8, 2022

Did you check how this behaves on Windows? IIRC, terminate already works the same as kill, and also KeyboardInterrupt may be received by any of the processes. Also, might consider only handling second Ctrl-C after a slight delay, as it is quite easy to accidentally hit it twice, but this is also not of that much importance (I don't mind if there is no delay required).

Nope, will check.

@ahopkins
Copy link
Member Author

I realize that is irrelevant since we do this:

if not OS_IS_WINDOWS:
    from signal import SIGKILL
else:
    SIGKILL = SIGINT

For Windows, the behavior is no different than it is today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants