-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-128307: support eager_start kwarg in create_eager_task_factory, and pass kwargs from asyncio.create_task and TaskGroup.create_task #128306
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
Changes from all commits
23d2c42
da5cab3
7bce401
8ad26fc
90f9ef2
1107608
ec3bd14
939c3f5
d24d43b
d8369c3
4a4ad1b
813398c
dfafc7a
3175aae
0598877
3e8e2a8
1c10063
5288bf2
14e0536
73a20a5
c92e2fa
8aab5f1
a410125
1a45d43
7654a85
74b02d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -386,19 +386,13 @@ def __wakeup(self, future): | |
Task = _CTask = _asyncio.Task | ||
|
||
|
||
def create_task(coro, *, name=None, context=None): | ||
def create_task(coro, **kwargs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the Python user perspective, I don't like this change. I suppose we'd be relying on https://github.com/python/typeshed/blob/main/stdlib/asyncio/tasks.pyi from now on? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree it would be nice if we could avoid the IDEs should be using typeshed anyway. (And we should update tasks.pyi to have a case for 3.14 that adds |
||
"""Schedule the execution of a coroutine object in a spawn task. | ||
graingert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Return a Task object. | ||
""" | ||
loop = events.get_running_loop() | ||
if context is None: | ||
# Use legacy API if context is not needed | ||
task = loop.create_task(coro, name=name) | ||
else: | ||
task = loop.create_task(coro, name=name, context=context) | ||
|
||
return task | ||
return loop.create_task(coro, **kwargs) | ||
|
||
|
||
# wait() and as_completed() similar to those in PEP 3148. | ||
|
@@ -1030,9 +1024,9 @@ def create_eager_task_factory(custom_task_constructor): | |
used. E.g. `loop.set_task_factory(asyncio.eager_task_factory)`. | ||
""" | ||
|
||
def factory(loop, coro, *, name=None, context=None): | ||
def factory(loop, coro, *, eager_start=True, **kwargs): | ||
return custom_task_constructor( | ||
coro, loop=loop, name=name, context=context, eager_start=True) | ||
coro, loop=loop, eager_start=eager_start, **kwargs) | ||
|
||
return factory | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add ``eager_start`` keyword argument to :meth:`asyncio.loop.create_task` |
Uh oh!
There was an error while loading. Please reload this page.