diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2018-08-08 21:06:47 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2018-08-08 21:06:47 (GMT) |
commit | cca4eec3c0a67cbfeaf09182ea6c097a94891ff6 (patch) | |
tree | 0d04ad10797fa95e5e09f8b32e8aa9e0c50f6aac /Lib/asyncio/base_events.py | |
parent | 52dee687af3671a31f63d6432de0d9ef370fd7b0 (diff) | |
download | cpython-cca4eec3c0a67cbfeaf09182ea6c097a94891ff6.zip cpython-cca4eec3c0a67cbfeaf09182ea6c097a94891ff6.tar.gz cpython-cca4eec3c0a67cbfeaf09182ea6c097a94891ff6.tar.bz2 |
bpo-34270: Make it possible to name asyncio tasks (GH-8547)
Co-authored-by: Antti Haapala <antti.haapala@anttipatterns.com>
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r-- | Lib/asyncio/base_events.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 78fe2a7..ee13d1a 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -384,18 +384,20 @@ class BaseEventLoop(events.AbstractEventLoop): """Create a Future object attached to the loop.""" return futures.Future(loop=self) - def create_task(self, coro): + def create_task(self, coro, *, name=None): """Schedule a coroutine object. Return a task object. """ self._check_closed() if self._task_factory is None: - task = tasks.Task(coro, loop=self) + task = tasks.Task(coro, loop=self, name=name) if task._source_traceback: del task._source_traceback[-1] else: task = self._task_factory(self, coro) + tasks._set_task_name(task, name) + return task def set_task_factory(self, factory): |