TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #401 · 15 дек.

Функция 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

Hashtags

Резултати

Пронајдени 4 слични објави

Пребарај: #gamelaunch

当前筛选 #gamelaunch清除筛选
SingSing Announcement

@singsingchannel · Post #1130 · 24.12.2024 г., 01:25

🌟Mystic Garden is Officially Open!🌟 🎉 The wait is over—step into the magic now! 🔸AURA Launchpool Stakers: Your AURA rewards are ready! 🔸Beta Testers: Enjoy 2x AURA on your deposits and beta test reward as a special thank-you! 🔸Everyone: It’s time to explore, grow, and thrive in Mystic Garden! Let the adventure begin! 🌱✨ Play Now: https://t.me/mystic_garden_bot/app #MysticGarden#GameLaunch#AURARewards

SingSing Announcement

@singsingchannel · Post #1125 · 22.12.2024 г., 02:05

🎄Christmas is Coming... and so is Mystic Garden!🌟 This holiday season, unwrap the magic with the official launch of Mystic Garden on Dec 24! 🌱✨ Get ready to plant, harvest, and earn as the garden blooms with festive cheer. 🎁 Don’t miss it! #MysticGarden#GameLaunch#PlayToEarn#Web3Gaming

SingSing Announcement

@singsingchannel · Post #814 · 21.09.2024 г., 05:07

🚀 The long-awaited SingSing Tycoon Game is about to launch! 🚀 ⏰Save the schedule:14:00 UTC Today - Sep 21⏰ In just a few hours, you’ll officially step into the world of SingSing Tycoon! Get ready to build your own karaoke chain, upgrade booths, expand your shop, and grow your ultimate entertainment empire! 🎤💰 Exciting adventures await. Be prepared—this is going to be epic! 💥 #SingSingTycoon#GameLaunch#KaraokeEmpire#PlayToEarn#SingSing Announcement | Chat | X (Twitter) | Website | Game

SingSing Announcement

@singsingchannel · Post #816 · 21.09.2024 г., 16:57

🚀SingSing Tycoon Game is Officially LIVE!🚀 The wait is over, SingSing Tycoon Game is Live Now 👉https://t.me/SingSing_TG_bot/app?startapp=_ktvgame Build your empire, compete with friends, and rise to the top! 💼🏆 Note: Lucky Box Owners and Kara Box Owners can now unbox in the Tycoon Game! 🎁✨ Don’t miss out—start your journey today! 🎮 #SingSingTycoon#GameLaunch#PlayNow#BuildYourEmpire 🎤Announcement | Chat | X (Twitter) | Website | Game