mirror of
https://github.com/python/cpython.git
synced 2025-09-04 16:01:10 +00:00
gh-128307: Support eager_start=<bool> in create_eager_task_factory and various create_task functions (#128306)
Some create_task() functions were changed from `name=None, context=None` to `**kwargs`. Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
This commit is contained in:
parent
c4cc5d58ae
commit
08d7687094
7 changed files with 85 additions and 19 deletions
|
@ -179,7 +179,7 @@ class TaskGroup:
|
|||
exc = None
|
||||
|
||||
|
||||
def create_task(self, coro, *, name=None, context=None):
|
||||
def create_task(self, coro, **kwargs):
|
||||
"""Create a new task in this group and return it.
|
||||
|
||||
Similar to `asyncio.create_task`.
|
||||
|
@ -193,10 +193,7 @@ class TaskGroup:
|
|||
if self._aborting:
|
||||
coro.close()
|
||||
raise RuntimeError(f"TaskGroup {self!r} is shutting down")
|
||||
if context is None:
|
||||
task = self._loop.create_task(coro, name=name)
|
||||
else:
|
||||
task = self._loop.create_task(coro, name=name, context=context)
|
||||
task = self._loop.create_task(coro, **kwargs)
|
||||
|
||||
futures.future_add_to_awaited_by(task, self._parent_task)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue