Browse Source

python 3.9 compatibility

master
Hendrik Langer 2 years ago
parent
commit
f5265f5c87
  1. 7
      matrix_pygmalion_bot/core.py

7
matrix_pygmalion_bot/core.py

@ -362,6 +362,13 @@ async def main() -> None:
bots.append(bot) bots.append(bot)
await bot.login() await bot.login()
print("gather") print("gather")
if sys.version_info[0] == 3 and sys.version_info[1] < 11:
tasks = []
for bot in bots:
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: async with asyncio.TaskGroup() as tg:
for bot in bots: for bot in bots:
task = tg.create_task(bot.client.sync_forever(timeout=30000, full_state=True)) task = tg.create_task(bot.client.sync_forever(timeout=30000, full_state=True))

Loading…
Cancel
Save