Use create_task instead of ensure_future

This commit is contained in:
Dan 2020-08-22 14:05:54 +02:00
parent a822c51261
commit 5f087e5f82
5 changed files with 8 additions and 8 deletions

View File

@ -115,7 +115,7 @@ class Dispatcher:
self.locks_list.append(asyncio.Lock())
self.handler_worker_tasks.append(
asyncio.ensure_future(self.handler_worker(self.locks_list[-1]))
self.loop.create_task(self.handler_worker(self.locks_list[-1]))
)
logging.info(f"Started {self.client.workers} HandlerTasks")
@ -148,7 +148,7 @@ class Dispatcher:
for lock in self.locks_list:
lock.release()
asyncio.ensure_future(fn())
self.loop.create_task(fn())
def remove_handler(self, handler, group: int):
async def fn():
@ -164,7 +164,7 @@ class Dispatcher:
for lock in self.locks_list:
lock.release()
asyncio.ensure_future(fn())
self.loop.create_task(fn())
async def handler_worker(self, lock):
while True:

View File

@ -101,7 +101,7 @@ class SaveFile(Scaffold):
return
try:
await asyncio.ensure_future(session.send(data))
await self.loop.create_task(session.send(data))
except Exception as e:
log.error(e)
@ -139,7 +139,7 @@ class SaveFile(Scaffold):
await self.storage.test_mode(), is_media=True
) for _ in range(pool_size)
]
workers = [asyncio.ensure_future(worker(session)) for session in pool for _ in range(workers_count)]
workers = [self.loop.create_task(worker(session)) for session in pool for _ in range(workers_count)]
queue = asyncio.Queue(16)
try:

View File

@ -65,6 +65,6 @@ class Restart(Scaffold):
if block:
await do_it()
else:
asyncio.ensure_future(do_it())
self.loop.create_task(do_it())
return self

View File

@ -60,6 +60,6 @@ class Stop(Scaffold):
if block:
await do_it()
else:
asyncio.ensure_future(do_it())
self.loop.create_task(do_it())
return self

View File

@ -59,7 +59,7 @@ class Syncer:
@classmethod
def start(cls):
cls.event.clear()
asyncio.ensure_future(cls.worker())
asyncio.get_event_loop().create_task(cls.worker())
@classmethod
def stop(cls):