Skip to content
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-128307: add eager_start kwarg to asyncio.create_task #128306

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

graingert
Copy link
Contributor

@graingert graingert commented Dec 28, 2024

@graingert graingert changed the title add eager_start to create_task gh-128307: add eager_start to create_task Dec 28, 2024
@graingert graingert changed the title gh-128307: add eager_start to create_task gh-128307: add eager_start kwarg to asyncio.create_task Dec 28, 2024
@graingert graingert force-pushed the add-eager-start-to-create-task branch from c809133 to 2f101b3 Compare December 28, 2024 10:58
task = self._task_factory(self, coro, context=context)

task.set_name(name)
task.set_name(name)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this set_name is too late because the task could have already run - so it needs a bit of thought

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

We can check first if the task factory exactly is eager_task_factory, and call it with all provided arguments.
The last resort for unknown task factory could have flaws.

On the other side, we can use inspect.signature() + some form of cache to analyze in runtime what arguments are accepted. I'm not a big fan of this approach, but maybe we have not choice.
Support of third-party tasks and factories adds a mess; we should live with it.

@asvetlov
Copy link
Contributor

TaskGroup.create_task() aslo should accept eager_start argument I guess.

@graingert
Copy link
Contributor Author

TaskGroup.create_task() aslo should accept eager_start argument I guess.

yup, it's in I just forgot to add it to the news

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants