loop: invoke asyncio.create_task() directly

asyncio.create_task() calls asyncio.get_running_loop() under the hood so
there is no need to call get_running_loop() ourselves if the sole
purpose is to create a task.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2022-10-07 18:25:03 +02:00
parent 0c67c1a998
commit 01567251f6
3 changed files with 3 additions and 4 deletions

View File

@ -174,7 +174,7 @@ class ErrorReport(metaclass=urwid.MetaSignals):
_bg_add_info()
context.description = "written to " + self.path
else:
self._info_task = asyncio.get_running_loop().create_task(add_info())
self._info_task = asyncio.create_task(add_info())
async def load(self):
with self._context.child("load"):

View File

@ -268,7 +268,7 @@ class SubiquityModel:
async def wait_confirmation(self):
if self._confirmation_task is None:
self._confirmation_task = asyncio.get_running_loop().create_task(
self._confirmation_task = asyncio.create_task(
self._confirmation.wait())
try:
await self._confirmation_task

View File

@ -36,5 +36,4 @@ class MessageHub:
await v
def broadcast(self, channel, *args, **kwargs):
loop = asyncio.get_running_loop()
return loop.create_task(self.abroadcast(channel, *args, **kwargs))
return asyncio.create_task(self.abroadcast(channel, *args, **kwargs))