Skip to content

Conversation

@hendrikmakait
Copy link
Contributor

@hendrikmakait hendrikmakait commented Sep 9, 2022

I will take over the original PR (#94973) from @graingert to get it over the finish line.

@ghost
Copy link

ghost commented Sep 9, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finishing this! I'll merge now.

@gvanrossum
Copy link
Member

Oh wait, it's still in draft. I'll leave it up to you to remove draft mode; ping the PR and I'll merge it then.

@hendrikmakait hendrikmakait marked this pull request as ready for review September 10, 2022 06:54
@hendrikmakait
Copy link
Contributor Author

@gvanrossum: Moved out of draft, thanks for the early review.

@gvanrossum gvanrossum merged commit 6281aff into python:main Sep 10, 2022
@gvanrossum gvanrossum added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Sep 10, 2022
@miss-islington
Copy link
Contributor

Thanks @hendrikmakait for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @hendrikmakait for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-96736 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Sep 10, 2022
@bedevere-bot
Copy link

GH-96737 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Sep 10, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 10, 2022
…o their task (pythonGH-96724)

Co-authored-by: Thomas Grainger <[email protected]>
Co-authored-by: Guido van Rossum <[email protected]>
(cherry picked from commit 6281aff)

Co-authored-by: Hendrik Makait <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 10, 2022
…o their task (pythonGH-96724)

Co-authored-by: Thomas Grainger <[email protected]>
Co-authored-by: Guido van Rossum <[email protected]>
(cherry picked from commit 6281aff)

Co-authored-by: Hendrik Makait <[email protected]>
@gvanrossum
Copy link
Member

Thanks Hendrik for finishing this up!

Thomas I hope you’re doing okay.

miss-islington added a commit that referenced this pull request Sep 10, 2022
…r task (GH-96724)

Co-authored-by: Thomas Grainger <[email protected]>
Co-authored-by: Guido van Rossum <[email protected]>
(cherry picked from commit 6281aff)

Co-authored-by: Hendrik Makait <[email protected]>
miss-islington added a commit that referenced this pull request Sep 10, 2022
…r task (GH-96724)

Co-authored-by: Thomas Grainger <[email protected]>
Co-authored-by: Guido van Rossum <[email protected]>
(cherry picked from commit 6281aff)

Co-authored-by: Hendrik Makait <[email protected]>
@Dreamsorcerer
Copy link
Contributor

Sorry that I'm bringing this up so late. But, is this actually needed?

It seems to me that shield() has a reference to the task, so this should not be needed (i.e. It returns outer, which has a reference to _outer_done_callback, which has a reference to inner in the enclosing scope, which is the task. As long as you have a reference to outer (i.e. by awaiting it), I don't think inner can be garbage collected).

If I'm wrong about that somewhere, shouldn't we just fix shield() to keep a reference, rather than asking the user to make this extra, non-obvious step every time they use it?

@graingert
Copy link
Contributor

@Dreamsorcerer when the result of shield is cancelled the reference to the original task is dropped

@Dreamsorcerer
Copy link
Contributor

Ah, yes, fair enough. Still feels like an explicit reference could be kept on outer to avoid this though.

But, with the proposed workaround, wouldn't the function that holds the task reference also likely be dropped (i.e. If the CancelledError bubbles up, the entire function scope will be discarded shortly thereafter)?
Seems like you'd need to put the reference somewhere globally or as an attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news topic-asyncio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants