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

Пребарај: #secondseason

当前筛选 #secondseason清除筛选
MoonPlay

@moonplay_official · Post #93 · 15.08.2024 г., 07:15

Let’s Conquer the Moon Together!🌕 Just landed on To The Moon!? Don’t worry - you’re joining at the perfect time as we kick off Season 3! Here’s how it works: 💸 mine Space Bucks, 🚀 upgrade your ship, 👥 invite friends & recruit a stellar crew, 🌌 play Star Dust to gain even more SP, 🏆 set off to the moon and level up! Every step you take brings you closer to token airdrop💸 after all 5 seasons. Focus on missions, levelling up, inviting referrals, and growing your space bucks balance. And for those of you who are starting out now, you’ve still got a shot at the airdrop by playing, conquering, and contributing to the mission. Ready to explore? Your adventure awaits! 👉TO THE MOON APP👈 Website | Telegram Chat | X | Discord | Medium #ToTheMoon#MoonPlay#ecosystem#blockchain#gamefi#web3#wenlisting#secondseason#communitymilestone#communityfirst#taptap#clicker#game

MoonPlay

@moonplay_official · Post #91 · 14.08.2024 г., 07:46

Shine Bright with Your Season 2 Badges and Win Big! 🪙 Season 2 was definitely one to remember: fierce competition, amazing Space Bucks balances, crazy level-ups 🆙, completed missions, and tons of new players joining To The Moon! via referral links 🤝. We've got plenty of reasons to celebrate! Just like we did in July - share your Achievement Badge from Season 2 2️⃣, and you could win a prize equal to the Space Bucks balance on it! Here's how to join in: 1️⃣ Follow the @moonplay_official group. 2️⃣Join our lively chat at @moonplay_chat. 3️⃣Drop a screenshot of your Season 2 Achievement Badge + use a hashtag #Season2 in the comments below this announcement. ⭐️To find your Season 2 Badge, just tap your profile in the top right and look under the Loot Capsules. We'll pick 20 lucky winners in 24 hours, so keep your eyes peeled! 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#secondseason#communitymilestone#communityfirst#taptap#clicker#game