Skip to content

fix TaskFactory and loop.create_task #13687

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

graingert
Copy link
Contributor

No description provided.

@graingert graingert force-pushed the fix-task-factory-and-loop-create-task branch from e0ad107 to 48f5574 Compare March 20, 2025 17:27

This comment has been minimized.

@graingert graingert closed this Mar 20, 2025
@graingert graingert deleted the fix-task-factory-and-loop-create-task branch March 20, 2025 18:29
@graingert graingert restored the fix-task-factory-and-loop-create-task branch April 9, 2025 17:24
@graingert graingert reopened this Apr 9, 2025

This comment has been minimized.

@graingert graingert marked this pull request as ready for review April 10, 2025 15:53
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

mitmproxy (https://github.com/mitmproxy/mitmproxy)
- mitmproxy/utils/asyncio_utils.py:96: error: Unused "type: ignore" comment  [unused-ignore]

pyodide (https://github.com/pyodide/pyodide)
+ src/py/pyodide/webloop.py:425: error: Signature of "create_task" incompatible with supertype "AbstractEventLoop"  [override]
+ src/py/pyodide/webloop.py:425: note:      Superclass:
+ src/py/pyodide/webloop.py:425: note:          def [_T] create_task(self, coro: Coroutine[Any, Any, _T], *, name: str | None = ..., context: Context | None = ..., eager_start: bool | None = ...) -> Task[_T]
+ src/py/pyodide/webloop.py:425: note:      Subclass:
+ src/py/pyodide/webloop.py:425: note:          def [T] create_task(self, coro: Coroutine[T, Any, Any], *, name: str | None = ..., context: Context | None = ...) -> Task[T]

@srittau
Copy link
Collaborator

srittau commented Apr 11, 2025

Considering that not all task factories have the eager_start argument (in particular the eager_task_factory), I think the best we can do is replace the eager_task_factory argument in the protocol with **kwargs: bool and explain in a comment that some factories support the eager_start argument and some don't.

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