From f5265f5c879841c7c27e67958fd5905c813c0bb5 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Sun, 2 Apr 2023 19:56:13 +0200 Subject: [PATCH] python 3.9 compatibility --- matrix_pygmalion_bot/core.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/matrix_pygmalion_bot/core.py b/matrix_pygmalion_bot/core.py index fa0252f..436d533 100644 --- a/matrix_pygmalion_bot/core.py +++ b/matrix_pygmalion_bot/core.py @@ -362,9 +362,16 @@ async def main() -> None: bots.append(bot) await bot.login() print("gather") - async with asyncio.TaskGroup() as tg: + if sys.version_info[0] == 3 and sys.version_info[1] < 11: + tasks = [] for bot in bots: - task = tg.create_task(bot.client.sync_forever(timeout=30000, full_state=True)) + task = asyncio.create_task(bot.client.sync_forever(timeout=30000, full_state=True)) + tasks.append(task) + await asyncio.gather(*tasks) + else: + async with asyncio.TaskGroup() as tg: + for bot in bots: + task = tg.create_task(bot.client.sync_forever(timeout=30000, full_state=True)) if __name__ == "__main__": asyncio.get_event_loop().run_until_complete(main())