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

Резултати

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

Пребарај: #season4

当前筛选 #season4清除筛选
MoonPlay

@moonplay_official · Post #104 · 02.09.2024 г., 05:47

Welcome to Season 4 🚀 Hey, Space Explorers! 3️⃣ is in the books, and wow, what a ride it has been! We’ve captured all your achievements as of 12 AM UTC — from those hard-earned Space Bucks to your referrals, levels, and missions completed. Your Season 3 Badge3️⃣ is waiting for you in your Profile, so go ahead and bask in that glory! Quick heads up: with the new season comes a fresh start. The progress of your space missions (levels and balances) has been reset. But don’t sweat it — each season is a new shot at reaching for the stars. 💫 New challenges, new strategies, and more flights to the moon. But don’t pack up your spacesuits just yet! Season 4 is already here!⭐️ It’s going to be an epic journey, and we couldn’t be more excited to see where this season takes us, especially with such an amazing community by our side. Ready for liftoff? Let’s make Season 4 one to remember! 🚀 👉TO THE MOON APP👈 Website | Telegram Chat | X | Discord | Medium #ToTheMoon#MoonPlay#ecosystem#blockchain#gamefi#web3#wenlisting#communityfirst#season4#taptap#clicker#game

MoonPlay

@moonplay_official · Post #120 · 24.09.2024 г., 09:49

Season 4 Badge Contest: Share & Win Big! 💰 Hey Space Cadets! 4️⃣ wrapped up yesterday, and it’s time to celebrate all your epic achievements! We’re excited to kick off our popular contest where you can show off your Season 4 Badge4️⃣ and have a chance to win big! Here’s how to join the fun: 1️⃣Follow the @moonplay_official group. 2️⃣Join our lively chat at @moonplay_chat. 3️⃣Share a screenshotof your Season 4 Badge and use the hashtag #Season4in the comments. ⭐️ To find your Season 4 Badge, just tap your profile in the top right and check under Loot Capsules. We’ll be picking 20 lucky winners in 24 hours, so keep an eye out! Good luck, and may your Badge shine the brightest! ✨ 👉TO THE MOON APP👈 Website | Telegram Chat | X | Discord | Medium #ToTheMoon#MoonPlay#ecosystem#blockchain#gamefi#web3#wenlisting#communityevent#communitymilestone#communityfirst#taptap#clicker#game