-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
bpo-31943: Add asyncio.Handle.cancelled() method #2388
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
Conversation
@decaz, thanks for your PR! By analyzing the history of the files in this pull request, we identified @1st1, @methane and @serhiy-storchaka to be potential reviewers. |
bb9c589
to
769d3d2
Compare
@1st1 should we support it? |
I'm OK with |
BTW, |
769d3d2
to
911c75c
Compare
f2facf7
to
575a7eb
Compare
575a7eb
to
0f8ac80
Compare
@1st1 yes, seconds_left = handler.when - loop.time() Now it's impossible as the time the handler will be called at is calculated internally. |
I specifically asked you about a real use case for ‘.when’. That means you should have told us about a real problem you encountered implementing a protocol or a server using asyncio, which was unsolvable without the ‘.when’ attribute. We won’t add something just because there are hypothetical use cases for it. |
0f8ac80
to
7510b17
Compare
@1st1 agree with you, just wanted to add such an attribute on the case if it will be convenient. I have rebased the branch. |
.. method:: cancelled() | ||
|
||
Return ``True`` if the call was cancelled. | ||
|
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.
Please add .. versionadded:: 3.6
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.
3.7 :)
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.
OK, added. I hope it will be backported to 3.6?)
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.
No. Asyncio is no longer provisional and this is not a bug fix.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
BTW |
I can see it improving the performance somewhat. But please hold off with the implementation before PEP 550 (or its successor) lands. |
7510b17
to
7c21485
Compare
I have made the requested changes; please review again. |
Thanks for making the requested changes! @asvetlov: please review the changes made to this pull request. |
Thanks for contribution! |
It would be handy to access the loop's time the Handle's callback will be called at if you are using delayed calls with "delay" (not "when") argument.
Also it is useful to know whether the call was cancelled through the special attribute.
https://bugs.python.org/issue31943