bpo-31943: Add asyncio.Handle.cancelled() method#2388
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. |
There was a problem hiding this comment.
Please add .. versionadded:: 3.6
There was a problem hiding this comment.
OK, added. I hope it will be backported to 3.6?)
There was a problem hiding this comment.
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