Функция asyncio.wait() это еще один способ вызвать множество асинхронных задач.
Она работает в нескольких режимах.
1. Самый простой - ждем завершения всех задач
async def main():
tasks = [asyncio.create_task(do_it(i)) for i in range(10)]
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.ALL_COMPLETED
)
for task in done:
try:
print(task.result())
except Exception as e:
print(e)
Очень похоже на gather, но работает не так.
▫️возвращает не результаты, а два сета с объектами Task у которых можно забрать результат через task.result() если они в списке done
▫️не гарантирует порядок результатов так как оба объекта это set
▫️не выбрасывает исключение когда оно появляется, а сохраняет его в Task. Исключение появится когда попробуете забрать резултьтат.
2. Ждем завершения первой задачи, даже если там ошибка.
async def main():
tasks = [asyncio.create_task(do_it(i)) for i in range(3)]
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.FIRST_COMPLETED
)
# в done может быть несколько задач!
for task in done:
try:
print(task.result())
except Exception as e:
print(f"Fail: {e}")
# Оставшиеся задачи в pending, как правило, нужно отменить, иначе они будут продолжать работать
for task in pending:
task.cancel()
В сете done будут таски которые успели завершится, причем как успешно так и нет.
3. До первой ошибки.
Тоже самое, но с аргументом FIRST_EXCEPTION
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.FIRST_EXCEPTION
)
Функция завершается как только первая задача упадет с ошибкой.
Учтите, что в любом случае done вы можете обранужить несколько задач, как с ошибками так и успешные.
↗️ Полный листинг примеров здесь
#async
😁Magids Abstract Armlocks by Magid Hage😁
➡️Get ready to see armlocks in a whole new light. In Magid’s Abstract Armlocks, world-class black belt and competition standout Magid Hage takes you deep into the world of unconventional, creative, and downright sneaky armlock attacks.
➡️Whether you're attacking from guard, top position, scrambles, or even from “bad” spots — you’ll learn how to hunt arms from anywhere.
$79😍$6.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#MagidHage#Submissions#NoGi#IBJJF
💁♀️Buy
💁♀️
😁Attacking Outside Finishing Inside by Lucas Kanard😁
➡️Unlock the secret to seamless offense with Attacking Outside, Finishing Inside, the revolutionary BJJ instructional series by Lucas Kanard.
➡️Designed to elevate your game by blending lower body attacks with precise upper body finishes, this system keeps your opponents guessing—and trapped.
̶$̶7̶9̶😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#LucasKanard#Passing#NoGi#Submissions
💁♀️Buy
💁♀️
🐈⬛NEW RELEASE
🐈⬛
🐈⬛Woj Lock 2.0 - Completing The Leg Lock Game by Chris Wojcik
🐈⬛
🐈⬛Chris Wojcik isn’t just a leg locker—he’s one of the most innovative finishers in modern grappling, known for catching high-level opponents with his signature “Woj Lock” system.
🐈⬛From foundational concepts to advanced 50/50 systems, cross ashi, inside ashi, and beyond—Wojcik shows you how to connect entries, control, and finishing mechanics into one seamless chain.
$79
🐈⬛$9.99
🐈⬛
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#ChrisWojcik#Submissions#NoGi#ADCC
🐈⬛Buy
🐈⬛
😁Z locks and the Diagonal Ashi:
the Complete Guide by Robert Degle😁
➡️More than any other leglocking strategy the Diagonal Ashi and Z lock allow us to remain safe from counter leglocks and solve the problem of defensive hip movement by allowing us to adhere to the principle of double trouble while we execute devastating leglock submissions.
$97😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#RobertDegle#Submissions#NoGi#ADCC
😁Samurai Submissions: finish Quickly From Turtle by Kenta Iwamoto😁
➡️In Samurai Submissions, BJJ’s fastest-rising star and B-Team standout breaks down his signature system for lightning-fast, high-percentage submissions from turtle — attacks so sneaky your opponents won’t realize they’re in danger until it’s already over.
➡️Kenta’s approach is brutally efficient: minimal movement, tight control, and submissions that hit before your opponent can react.
$127😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#KentaIwamoto#Submissions#NoGi#CJI
🔥NEW RELEASE🔥
😁Upper Lower Chains Links that Solve Problems Faster by Josh Saunders😁
➡️Unlock the secret to faster problem-solving and fluid movement on the mats with Upper Lower Chains Links that Solve Problems Faster, an innovative BJJ instructional by Josh Saunders — a 2x ADCC Trials winner and ADCC semifinalist.
➡️This groundbreaking approach empowers practitioners to adapt, innovate, and respond to challenges in real-time, making your game more dynamic and intuitive.
$79😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#JoshSaunders#Submissions#NoGi#Transitions
💁♀️Buy
💁♀️
😁Rethink Front Headlocks: Control And Submit Larger People by Josh Janis😁
➡️Discover a smarter, more effective way to dominate from the front headlock—especially against larger, stronger opponents.
➡️With this series, you’ll learn how to systematically break posture, create off-balance reactions, and chain submissions—even on opponents who normally overpower you.
$79😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#JoshJanis#Guillotines#NoGi#Submissions
💁♀️Buy
💁♀️