Repository navigation
Conversation
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Author
|
Could a maintainer review this change to return cancellable handles for postponed callbacks? Please let me know whether this API is in scope or if changes or further cases are needed before review. Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1012.
Return a cancellable
asyncio.Handlefromcall_soon_threadsafewithout changing its synchronous calling convention. With no postponement, return the event loop's handle directly. With postponement, keep one cancellation token across scheduling retries and check it before running or rescheduling the callback.This lets callers cancel after the first postponement, rather than only cancelling the first scheduled attempt. Existing callers that ignore the return value keep the same behavior. Cancellation does not interrupt a callback that has already started. This does not change Application redraw lifecycle behavior.
The tests cover cancellation before dispatch and after a retry, idle and deadline dispatch, loops without
_ready, context propagation, callback errors reaching the loop's exception handler, scheduling from another thread, and the implicit running loop.Validation on Linux:
None.