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

Пребарај: #ogcommunity

当前筛选 #ogcommunity清除筛选
MoonPlay

@moonplay_official · Post #40 · 24.06.2024 г., 18:59

New Partnership Announcement: MoonPlay x OGCommunity!🚀 Hey Space Cadets! Kick-starting this week with the announcement of our partnership with👾OGCommunity - a powerhouse in the gaming industry with over 2 million members. They have something for everyone: communication with like-minded people, learning something new, earning money, investing, influencing the development of the industry, developing and launching projects in gaming, taking part in eSports tournaments, and playing the most exciting games. Together, we’re set to elevate your gaming experience to cosmic heights! 🔝 What This PartnershipMeans for You: 👥Enhanced Community: Benefit from the expertise and influence of one of the most impactful communities in gaming. 💸New Opportunities: Discover unique ways to earn, invest, and play, brought to you by the combined efforts of MoonPlay and OGCommunity. ✅Industry Influence: Be part of a movement that shapes the future of gaming, supported by a robust ecosystem of projects and initiatives. Together with OGCommunity, we’re bringing more excitement, innovation, and opportunities to your space adventures. Stay tuned for more updates 👀 as we embark on this stellar journey together! Stellar adventures start here:@moon_land_bot🚀 JOIN OGCOMMUNITY: ✉Channel ❌Twitter 🤖Discord *⃣Linktr.ee🐝Blog🐝OGC App #ToTheMoon#OGCommunity#MoonPlay#partnership#ecosystem#blockchain#gamefi#web3#wenlisting#airdropsoon#communityfirst#taptap#clicker#game

MoonPlay

@moonplay_official · Post #67 · 16.07.2024 г., 17:33

New Mission Pack Alert 👀 OGCommunity, known for building the most influential community and ecosystem in the gaming industry, brings you a fresh pack of missions! Connect with over 2 million members 👥, gain new knowledge, and take part in epic gaming experiences. 👉 Head right to Missions tab and complete special tasks curated by OGCommunity to earn rewards. Don't miss out on this opportunity. Together, we’ll conquer the cosmos and build a thriving lunar colony! 🤩 👉Start your To The Moon adventure now!👈 Website | Telegram Chat | X | Discord | Medium #ToTheMoon#MoonPlay#OGCommunity#ecosystem#blockchain#gamefi#web3#wenlisting#squad#mission#communityfirst#taptap#clicker#game