Switch from low-level loop.create_task and asyncio.ensure_future (#5626)

* Switch from low-level loop.create_task and asyncio.ensure_future

* Patch vendored discord.ext.menus to use modern APIs as well

That ext is no longer maintained by Danny anyway so...

* black
This commit is contained in:
jack1142
2022-03-21 17:24:46 +01:00
committed by GitHub
parent 7a5ada2d92
commit ed4f2cf466
15 changed files with 27 additions and 37 deletions

View File

@@ -90,8 +90,8 @@ async def menu(
try:
predicates = ReactionPredicate.with_emojis(tuple(controls.keys()), message, ctx.author)
tasks = [
asyncio.ensure_future(ctx.bot.wait_for("reaction_add", check=predicates)),
asyncio.ensure_future(ctx.bot.wait_for("reaction_remove", check=predicates)),
asyncio.create_task(ctx.bot.wait_for("reaction_add", check=predicates)),
asyncio.create_task(ctx.bot.wait_for("reaction_remove", check=predicates)),
]
done, pending = await asyncio.wait(
tasks, timeout=timeout, return_when=asyncio.FIRST_COMPLETED