-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
GH-124639: add back loop param to staggered_race #124700
Conversation
kumaraditya303
commented
Sep 27, 2024
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: Please restore the loop param to staggered.staggered_race #124639
I think |
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.
Could you add a deprecation warning when loop is not None (or maybe only if it’s not equal to tg._loop)?
I'll handle change for 3.14 separately, let's first get this done so that it can be backported to stable releases. We cannot add deprecations to stable releases AFAIR. |
Got it!
…--Guido (mobile)
On Fri, Sep 27, 2024 at 12:19 Kumar Aditya ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In Lib/asyncio/staggered.py
<#124700 (comment)>:
> @@ -82,7 +82,11 @@ async def run_one_coro(this_index, coro_fn, this_failed):
raise _Done
try:
- async with taskgroups.TaskGroup() as tg:
+ tg = taskgroups.TaskGroup()
+ # Intentionally override the loop in the TaskGroup to avoid
+ # using the running loop, preserving backwards compatibility
+ tg._loop = loop
Also how sure are you that TaskGroup doesn’t use its _loop before you get
to this point?
Taskgroup only starts using the loop after __aenter__
https://github.com/python/cpython/blob/0881e2d3b1212d988733f1d3acca4011ce5e6280/Lib/asyncio/taskgroups.py#L54-L60
See lines 58-59
—
Reply to this email directly, view it on GitHub
<#124700 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAWCWMSEGTWSCE2YI57CY3LZYWVTBAVCNFSM6AAAAABO7XLLR2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDGMZUGQ3TONJSGI>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
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.
LGTM. I don't know if the bot will like the 3.13 backport, because the backport for the original PR never got merged (unless I missed that, IIRC Kirill added DO-NOT-MERGE
).
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.
Looks good to me.
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.
Sorry, needs a test.
When you're done making the requested changes, leave the comment: And if you don't make the requested changes, you will be put in the comfy chair! |
@kumaraditya303 Why did you mark this as a release blocker? The original PR has not been backported to 3.13. Or is it only a blocker for 3.12? My guess is (and I would agree) that Thomas will not allow the original PR in 3.13.0, and then this can't be merged there either. It can all go into 3.13.1, as well as into the 3.12 branch, of course. Let's just make sure that the original PR doesn't go into a 3.12 release without this one as well. (I will next actually review the test.) |
@@ -121,6 +121,25 @@ async def coro(index): | |||
self.assertIsInstance(excs[0], ValueError) | |||
self.assertIsNone(excs[1]) | |||
|
|||
def test_loop_argument(self): |
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.
Ah, so this is just the original test restored. See my comment #124639 (comment) for why I'm not yet approving this.
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.
Hm, I'm not so sure there ever were tests for staggered in 3.12. What I thought I saw was probably in a different branch. :-( Sorry.
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.
There was no tests for it and still has less in main than it should
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.
Tested on a production system, details
#124639 (comment)
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.
This version can go in, since it does the right thing when the current loop is passed in using loop=get_running_loop()
(which is the only use case in aiohttp -- they just pass it in redundantly). We really need to land the 3.12 backport ASAP, since the next 3.12 release happens Tuesday (Oct 1).
However, if you pass a different eventloop (e.g. loop=new_event_loop()
) things break terribly (I tried this in the test and it just hung).
Consider rolling back the TaskGroup hack (and the comment, alas) and instead just checking that loop is None or loop is get_running_task()
, raising ValueError
if it isn't.
But that can be a separate PR, so you don't have to stress about the release, or how to test it.
It's a blocker for 3.12 so I marked it |
Thanks @kumaraditya303 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
Sorry, @kumaraditya303, I could not cleanly backport this to
|
(cherry picked from commit e0a41a5) Co-authored-by: Kumar Aditya <kumaraditya@python.org>
GH-124744 is a backport of this pull request to the 3.12 branch. |
…wnstream (pythonGH-124810) * Revert "pythonGH-124639: add back loop param to staggered_race (pythonGH-124700)" This reverts commit e0a41a5. * Revert "pythongh-124309: Modernize the `staggered_race` implementation to support eager task factories (pythonGH-124390)" This reverts commit de929f3. (cherry picked from commit 133e929) Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
…ownstream (GH-124810) (#124817) gh-124309: Revert eager task factory fix to prevent breaking downstream (GH-124810) * Revert "GH-124639: add back loop param to staggered_race (GH-124700)" This reverts commit e0a41a5. * Revert "gh-124309: Modernize the `staggered_race` implementation to support eager task factories (GH-124390)" This reverts commit de929f3. (cherry picked from commit 133e929) Co-authored-by: Peter Bierma <zintensitydev@gmail.com>