Improve graceful shutdown #938
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Turns out we were wasting a lot of time for no reason while doing graceful shutdown, this PR fixes it. This almost fixes #711 — the shutdown is fast enough that it isn't really frustrating. Sometimes telegram still takes a bit of time to respond to the last
get_updatesrequest1, so I think we should still implement the "multiple ^C for forceful shutdown" (additionally it would help for cases when handlers are stuck).Here is a comparison of new version (this PR/branch) and old one (current master)23:
Peek.2023-09-25.22-05.mp4
Footnotes
I think it happens when last
get_updatescall and the previous one happen with little delay between them ↩Note that in second runs of both versions a wait for like 10s or so and the shutdown is much faster for those cases, that's the telegram quirk, I think ↩
I'm so dead by the fact that the new version is so much faster4, like... we could have had this all along 💀 we received so many complaints about the slow shutdown, and it turns out it was almost entirely our fault 💀 ↩
the first run is 18s -> 3s (6x times faster), the second one is 10s (11s waiting) -> less than a second (8s waiting) (that's so much faster aaaaa) ↩