Skip to content

gh-113050: Pass name to BaseEventLoop task factory #113051

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

Closed

Conversation

ordinary-jamie
Copy link
Contributor

@ordinary-jamie ordinary-jamie commented Dec 13, 2023

Issue: #113050

The task factory is used in the BaseEventLoop create_task method when set. This commit passes the name kwarg to this factory to set the name of the task, instead of setting the task in the loop method. This is more consistent with the eager_task_factory methods.

This is consistent with:

This will be a breaking change if and only if:

  • The BaseEventLoop is subclassed and the subclass does not override create_task (using the default implementation), and
  • The subclass is used with a task factory that does not accept the name kwarg (or **kwargs).

uvloop will not be affected by this, but I have raised an issue to update their typing to reflect this expectation: MagicStack/uvloop#584


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

@ordinary-jamie
Copy link
Contributor Author

This is a pretty naive approach, but I used Github search to look for Python projects that subclass BaseEventLoop, then from there checked if they either overrode create_task (and hence not affected) or if they use set_task_factory in a breaking way.

List of Github Projects that subclass BaseEventLoop:

Project Stars Notes
vxgmichel/aiostream 606 Only uses loop for testing
dbrattli/aioreactive 323 Does not use task factory
fantix/kloop 194 Does not use task factory
Bubobubobubobubo/sardine 152 Does not use task factory
beeware/gbulb 62 Does not use task factory
nolar/looptime 24 Does not use task factory
fancidev/qtinter 16 Does not use task factory

The task factory is used in the BaseEventLoop create_task method when
set. This commit passes the `name` kwarg to this factory to set the
name of the task, instead of setting the task in the loop method. This
is more consistent with the eager_task_factory methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant