-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix graceful shutdown #3662
Fix graceful shutdown #3662
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3662 +/- ##
==========================================
- Coverage 97.9% 97.82% -0.08%
==========================================
Files 43 43
Lines 8556 8566 +10
Branches 1376 1379 +3
==========================================
+ Hits 8377 8380 +3
- Misses 74 78 +4
- Partials 105 108 +3
Continue to review full report at Codecov.
|
@asvetlov Are there plans to merge this or something similar in the near future? Graceful shutdowns, as documented in https://aiohttp.readthedocs.io/en/stable/web_advanced.html#aiohttp-web-graceful-shutdown, do not work on 3.5.4. (clients get an empty response as soon as the aiohttp process gets a SIGTERM or SIGINT) |
Hi. Note to myself: |
|
||
|
||
class GracefulExit(SystemExit): | ||
class ForceExit(SystemExit): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't rename it, it's exposed and can be used by end-users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs rebasing and reverting the GracefulExit
I ran into this problem and came across this PR. I think the problem was indeed introduced in the mentioned commit, but specifically this line: dd30b2a#diff-8e4ccf3aaf43100064462a4df10952e5R214 That line cancels all running tasks in the event loop, so also tasks that were scheduled as background tasks. After cancelling everything, it waits for them to finish. Since In my case, I tried to handle shutdown gracefully by setting a flag and letting the background task gracefully exit, but it's already cancelled because of I think this PR does not fix that particular problem. |
I believe the issue is fixed by #3805 |
What do these changes do?
Graceful shutdown not working properly since commit dd30b2a
When a long running request is in progress, and the server is being gracefully closed, all handlers are immediately stopped the client receive a empty response.
These changes make the server stop accepting new connections, process existing ones properly and then exit.
Are there changes in behavior for the user?
On first SIGINT/SIGTERM the server will try to gracefully close all handlers and quit.
If for some reason a handler is stuck, sending a second SIGINT/SIGTERM will force the server to quit immediately
Related issue number
#3638
Checklist
CONTRIBUTORS.txt
CHANGES
folder<issue_id>.<type>
for example (588.bugfix)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.