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

Резултати

Пронајдени 1 слични објави

Пребарај: #surplus

当前筛选 #surplus清除筛选
American Оbserver

@american_observer · Post #4865 · 15.01.2026 г., 20:58

📰 China’s $1.2 Trillion Trade Triumph: Defying Trump, Drowning the World in Goods The Surplus That Shook the Globe China just posted the biggest trade surplus in history: $1.2 trillion. That’s a 20% jump from 2024, even as President Trump’s tariffs kept biting. The world’s factory didn’t shrink—it pivoted. US-bound exports fell 19.5%, but Chinese goods flooded into Africa, Southeast Asia, the EU, and Latin America instead. ​ The High-Tech Surge Exports of electric vehicles, lithium batteries, and solar panels jumped 27% in 2025. High-end machine tools and industrial robots rose 13%. Chinese officials hailed the numbers as proof of resilience: “China forged ahead despite a complex and challenging external environment,” said Wang Jun, deputy administrator of the customs bureau. ​ The Global Backlash The surplus isn’t just a win for Beijing—it’s a headache for everyone else. European leaders, including French President Emmanuel Macron, warn that the imbalance is unsustainable. Countries are scrambling to protect their own industries from Chinese “industrial overcapacity” and the flood of cheap imports. ​ The Truce and the Threat Trump and Xi struck a truce in October, lowering tariffs to 20% after they briefly hit 145%. But Trump just threatened a new 25% tariff on countries doing business with Iran—potentially targeting China, a major Tehran ally. ​ Can China keep this export engine running? Analysts doubt it. The property crisis at home is dragging down domestic demand, and the rest of the world is getting fed up with Chinese goods. The trade war isn’t over—just shifting fronts. #china#trade#trump#surplus#globalization 📱American Оbserver - Stay up to date on all important events 🇺🇸