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 слични објави

Пребарај: #blinkmemecontest

当前筛选 #blinkmemecontest清除筛选
Blink Game AI

@blink_en · Post #21 · 28.10.2024 г., 12:01

🎉 Blinkers, your memes are on fire! Each new post makes us smile even more — keep up the great work! Reminder: the best memes will win 2000 $BLINK and 10 USDT! Our community is still growing, so your chances of winning are high. 📅 Deadline: October 30. If you haven’t joined yet, now’s the time to show off your creativity! How to participate: 1. Create funny memes about blinking (post as many as you like!). 2. Share them on Twitter with the hashtags #BLINKMEMECONTEST and #MiniApp, and tag our Twitter account @blinkgameapp. Show us your creativity, and we’ll make sure to notice you! ❤️ Open Blink Game AI: Blink and Earn! 💵 ENG Chat | RU Chat Twitter | Discord | Instagram | YouTube | TikTok | CIS TG

Blink Game AI

@blink_en · Post #18 · 26.10.2024 г., 17:16

🤑Create a funny blink meme and earn 2000 $BLINK and 10 USDT! Join our meme contest and show off your sense of humor! Memes, GIFs, videos — anything that makes us and your followers laugh and supports the idea of our app. How to participate: 1. Create a creative meme on the theme of blinking and Blink Game AI. 2. Post it on your Twitter with the hashtags #BLINKMEMECONTEST and #MiniApp, and tag our Twitter account @blinkgameapp. 💵 The creators of the 10 funniest memes will receive 2000 $BLINK and 10 USDT each. Contest period: 26.10.2024–30.10.2024 Time to shine — let the world see your creativity! Open Blink Game AI: Blink and Earn! 💵 Twitter | Discord | Instagram | YouTube | TikTok | CIS TG