Get rid of client.loop

Instead, use the asyncio-intended way of implicit loop.
This commit is contained in:
Lonami Exo
2022-01-16 13:51:23 +01:00
parent 6eadc8aed8
commit a62627534e
19 changed files with 140 additions and 177 deletions

View File

@@ -159,14 +159,14 @@ def _process_update(self: 'TelegramClient', update, entities, others):
channel_id = self._state_cache.get_channel_id(update)
args = (update, entities, others, channel_id, self._state_cache[channel_id])
if self._dispatching_updates_queue is None:
task = self.loop.create_task(_dispatch_update(self, *args))
task = asyncio.create_task(_dispatch_update(self, *args))
self._updates_queue.add(task)
task.add_done_callback(lambda _: self._updates_queue.discard(task))
else:
self._updates_queue.put_nowait(args)
if not self._dispatching_updates_queue.is_set():
self._dispatching_updates_queue.set()
self.loop.create_task(_dispatch_queue_updates(self))
asyncio.create_task(_dispatch_queue_updates(self))
self._state_cache.update(update)