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

Пребарај: #hdbplus65

当前筛选 #hdbplus65清除筛选
HDB

@SingaporeHDB · Post #2711 · 15.02.2025 г., 04:08

🏠✨ This year, HDB marks 65 years of housing a nation! For 65 years, HDB homes have shaped the Singaporean way of life. We grew up playing “catching” with friends at the playground, stopping by the neighbourhood heartland shop for a quick snack, and enjoying comforting meals at the coffeeshop with our families. Over the decades, these familiar spaces found in every estate have become cherished and iconic symbols of HDB living – and will remain so for generations to come. Can you recognise this iconic HDB space? Stay tuned for #HDBplus65 as we celebrate the places that make HDB living special!

Hashtags

HDB

@SingaporeHDB · Post #2901 · 15.08.2025 г., 03:10

🎁Join our HDB+You Instagram giveaway and win a little piece of the heartlands to bring along with you, wherever you might be. Giveaway ends 4 Sep 2025 (11:59pm), 20 winners will be drawn. P.S. Learn more about HDB’s 65th birthday and our collaboration with local artist Hello Jayne! #HDBplus65#SG60

HDB

@SingaporeHDB · Post #2890 · 05.08.2025 г., 10:12

👥 Who’s your heartland bestie? ➡️Share the HDB+Me quiz with your friends, and discover your unique heartland personalities. P.S. Did you know? It’s HDB’s 65th birthday this year! Learn more about our collaboration with local artist Hello Jayne. #HDBplus65#SG60

HDB

@SingaporeHDB · Post #2888 · 01.08.2025 г., 04:09

The well-loved playground, welcoming void deck or the popular fitness corner – which of these heartland icons most resembles your personality? Join us on an adventure and discover your unique heartland personality! 👉Take the HDB+Me personality quiz and celebrate HDB’s 65th anniversary with us! ❤️🤍 Brought to you in collaboration with local artist Hello Jayne #HDBplus65#SG60