We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6afb25f commit 8808794Copy full SHA for 8808794
Lib/asyncio/tasks.py
@@ -384,12 +384,19 @@ def __wakeup(self, future):
384
Task = _CTask = _asyncio.Task
385
386
387
-def create_task(coro, **kwargs):
+def create_task(coro, *, name=None, context=None):
388
"""Schedule the execution of a coroutine object in a spawn task.
389
390
Return a Task object.
391
"""
392
- return events.get_running_loop().create_task(coro, **kwargs)
+ loop = events.get_running_loop()
393
+ if context is None:
394
+ # Use legacy API if context is not needed
395
+ task = loop.create_task(coro, name=name)
396
+ else:
397
+ task = loop.create_task(coro, name=name, context=context)
398
+
399
+ return task
400
401
402
# wait() and as_completed() similar to those in PEP 3148.
0 commit comments