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

Пребарај: #economicgeography

当前筛选 #economicgeography清除筛选
Amazing Geography 🌍

@amazingeo · Post #675 · 28.03.2026 г., 20:31

🌍 Since the 1960s, Dubai’s desert coast has transformed into a global business hub through free trade zones, drawing global companies and turning once barren sands into a vibrant economic powerhouse. ✨ #economicgeography⚡#trade⚡#urbanization⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #332 · 04.10.2025 г., 18:31

🌍 The Chicago area is the world’s largest concentration of inland rail and freight connections, making it a vital hub where goods from coasts and the Midwest converge before heading nationwide. ✨ #economicgeography⚡#transport⚡#trade⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #178 · 05.09.2025 г., 00:12

🌍 More than half of global economic activity now takes place within just 1% of the world’s land surface, showing how powerful major cities and industrial regions are for global wealth. ✨ #economicgeography⚡#cities⚡#industry⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #292 · 24.09.2025 г., 18:31

🌍 Japan’s Tokaido corridor between Tokyo and Osaka packs over 60 million people and is a global hub for high-speed trains, industry, and services, shaping a megaregion central to Asia’s economy. ✨ #economicgeography⚡#megaregion⚡#infrastructure⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​