GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [3.13] gh-128308: Revert "pass `**kwargs` to asyncio task_factory (GH-128768) (#130084)" by kumaraditya303 · Pull Request #133808 · python/cpython

Conversation

@kumaraditya303

@kumaraditya303 kumaraditya303 commented May 10, 2025 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This reverts commit 7b0543e.

  • Issue: asyncio eager tasks' names are set too late #128308

📚 Documentation preview 📚: https://cpython-previews--133808.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kumaraditya303
Revert "[3.13] pythongh-128308: pass **kwargs to asyncio task_facto…
5874f08
…ry (pythonGH-128768) (python#130084)"

This reverts commit 7b0543e.
@bedevere-app bedevere-app Bot mentioned this pull request May 10, 2025
asyncio eager tasks' names are set too late #128308
Closed
@kumaraditya303 kumaraditya303 changed the title Revert "[3.13] gh-128308: pass **kwargs to asyncio task_factory (GH-128768) (#130084)" [3.13] gh-128308: Revert pass **kwargs to asyncio task_factory (GH-128768) (#130084)" May 10, 2025
@bedevere-app bedevere-app Bot added the topic-asyncio label May 10, 2025
@bedevere-app bedevere-app Bot mentioned this pull request May 10, 2025
[3.13] gh-128308: pass **kwargs to asyncio task_factory (GH-128768) #130084
Merged
@blurb-it
📜🤖 Added by blurb_it.
9f73793
@kumaraditya303
kumaraditya303 marked this pull request as ready for review May 10, 2025 09:02
@kumaraditya303
kumaraditya303 requested review from 1st1, asvetlov, gvanrossum and willingc as code owners May 10, 2025 09:02
@bedevere-app bedevere-app Bot added the awaiting core review label May 10, 2025
@kumaraditya303
kumaraditya303 requested a review from Yhg1s May 10, 2025 09:34
@kumaraditya303 kumaraditya303 mentioned this pull request May 10, 2025
Breaking API Change in Python 3.13.3: Task Factory Signature Change #133745
Closed
gvanrossum
gvanrossum approved these changes May 10, 2025
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

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.

Only the backport is being reverted right? Please explain in the commit message why.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels May 10, 2025
@gvanrossum

gvanrossum commented May 10, 2025

Copy link
Copy Markdown
Member

Does this spell doom for the 3.14 change???? @graingert

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@graingert

graingert commented May 10, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I don't think so, a new kwarg context was added and passed in asyncio.Runner in 3.11 so there's precedent for this sort of change. For eager_start we're adding it but not passing it anywhere so it's not breaking any existing code. For name it's being passed and added.

If we decide passing name is breaking (and passing context was also breaking and we agree it shouldn't have been added) we can pop name from the kwargs in BaseEventLoop.create_task and use a flag and deprecation cycle to add it back like @serhiy-storchaka suggested. The feature for the eager_start is still valid

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz picnixz changed the title [3.13] gh-128308: Revert pass **kwargs to asyncio task_factory (GH-128768) (#130084)" [3.13] gh-128308: Revert "pass **kwargs to asyncio task_factory (GH-128768) (#130084)" May 10, 2025
@gvanrossum

gvanrossum commented May 10, 2025

Copy link
Copy Markdown
Member

So it just shouldn’t have been backported. Sorry.

somehow I can’t find the issue suggesting the revert.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented May 10, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

See #133745. That argument applies to 3.14 too. In fact we broke the “name, context may be positional” for create task?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@graingert

graingert commented May 10, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Ah yes definitely! I'll get a PR for 3.14 to fix the positional behavior for name and context ah no they were keyword only

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented May 10, 2025

Copy link
Copy Markdown
Member

name and context always were keyword only.

But we broke explicit context=None. create_task(coro, context=None) did not pass context to the task factory.

gvanrossum reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal

pablogsal commented May 10, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Notice that several people have implemented workarounds since then so we need to ensure we preserve both behaviors to not break the people that have adapted. For example: beeware/toga#3395

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented May 10, 2025

Copy link
Copy Markdown
Member

Looks like we have more work to do -- 3.13.4 must support the workarounds that people have already made for 3.13.3.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alicederyn

alicederyn commented May 12, 2025

Copy link
Copy Markdown

FWIW as one of the people who made a workaround, we just followed the documentation and passed through **kwargs, which is compatible with a simple revert; beeware/toga have also done it this way. As well as being the new documented contract, this is also the simplest way to remain compatible with Python 3.12 and earlier, so hopefully most people will have done the same.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented May 12, 2025

Copy link
Copy Markdown
Member

Thanks @alicederyn, that's very helpful.

alicederyn reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented May 12, 2025

Copy link
Copy Markdown
Member

@graingert Are you going to update this PR to not break the workaround described by @alicederyn ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@graingert

graingert commented May 12, 2025

Copy link
Copy Markdown
Contributor

Does a plain revert break the workaround?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented May 12, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Does a plain revert break the workaround?

I think so. Pre-revert (but only in 3.13.3), you could have a "private" keyword parameter passed to create_task() that's passed on to your factory (assuming you have control over the factory and your factory accepts this private keyword). So I think the various create_task() methods should (in addition to name= and context=) grow a new **kwargs that just is passed on to the factory or task (causing an error if it's not expected).

It's possible that that fix also models the improved version for 3.14b2 (which should pop name and cancel context if they're None, IIUC).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@graingert

graingert commented May 12, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Ah right, that's a better option!

I'm not sure about this:

and cancel if they're None, IIUC).

Do you mean Task.cancel(), or abort with RuntimeError, or coro.close(), or something else?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented May 12, 2025

Copy link
Copy Markdown
Member

Sorry, "and cancel" should have been "and context". Will fix in the original.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@graingert

graingert commented May 12, 2025

Copy link
Copy Markdown
Contributor

Do you want to always pop name in 3.13.4?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented May 12, 2025

Copy link
Copy Markdown
Member

So, passing name= through kwargs to the factory must be a feature that factories must support to be compatible with 3.13.3 (but not later versions of 3.13), and to be compatible with 3.14b1+. 3.13.4+ must revert to the lame setname call to send the factory the name (a very old hack to be compatible with earlier versions of uvloop IIRC), but for 3.14b2 and everything after we require factories to support passing name= via **kwargs, and won't do the setname call any more. Right?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented May 12, 2025

Copy link
Copy Markdown
Member

Do you want to always pop name in 3.13.4?

I think so, since pre-3.13.3 factories may not support any keywords (other than and empty dict) and IIUC there's no way to tell if a factory supports that or requires setname, and I don't want to introduce a new API so we could ask a task factory about this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@graingert

graingert commented May 12, 2025

Copy link
Copy Markdown
Contributor

Ok I opened up a draft here: #133948

the news fragment is going to be fun, I've left it blank for now

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kumaraditya303 kumaraditya303 closed this May 18, 2025
@kumaraditya303
kumaraditya303 deleted the revert branch June 13, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gvanrossum gvanrossum gvanrossum approved these changes
@1st1 1st1 Awaiting requested review from 1st1 1st1 is a code owner
@asvetlov asvetlov Awaiting requested review from asvetlov asvetlov is a code owner
@willingc willingc Awaiting requested review from willingc willingc is a code owner
@Yhg1s Yhg1s Awaiting requested review from Yhg1s

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting merge topic-asyncio

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@kumaraditya303 @gvanrossum @graingert @serhiy-storchaka @pablogsal @alicederyn
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.