Allow closing the bot during StartingEvent #1746
Draft
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.
Summary
Allows the following use-case:
This would be the gist of the change as things currently stand, but I am not entirely happy with it. Ideally, we would want any interrupt or call to
bot.close()
(which should really resolve to the same thing internally to streamline the shutdown process, imo) at any point in time to immediately start the shutdown sequence.When I get some time, I will play around with implementing the signal handling directly into the loop and (maybe) an event being set stops the loop and makes it continue to the shutdown phase rather than having to keep checking for the the event being set.
Any feedback on this is welcome!
Note for myself (probably wont be changed):
I also dislike how its a bit counter intuitive to check for
None
other than the event being set, but until CPython 3.11 we will not be able to change that sinceasyncio.Event
tries to get the loop in__init__
.Checklist
nox
and all the pipelines have passed.