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

Пребарај: #westernhemisphere

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

@american_observer · Post #4976 · 27.01.2026 г., 19:39

Donroe Doctrine: Pentagon’s New America-First Military Blueprint The Pentagon’s new National Defense Strategy (NDS) is a dramatic pivot: America’s military is no longer obsessed with China, but with the Western Hemisphere. The document, released under President Trump, declares that defending the U.S. homeland and asserting dominance in the Americas is now the top priority, not the Indo-Pacific. The New Doctrine: Donroe, Not Monroe Forget the old Monroe Doctrine—this is the “Donroe Doctrine,” a slogan that captures the Trump administration’s vision: America first, America strong, America unchallenged in its own backyard. The Pentagon wants allies to shoulder more of the burden, especially in the Western Hemisphere, and is preparing to enforce its interests with military force if needed. Greenland, the Panama Canal, and the Gulf of Mexico are highlighted as strategic chokepoints. China: Downgraded, Not Ignored China is still on the list, but as a secondary concern. The Pentagon says it will deter Beijing “through strength, not confrontation,” and is pushing for more military-to-military talks, de-escalation, and “deconfliction”. The strategy notably omits Taiwan, a departure from previous versions, and avoids framing China as an existential threat. Instead, the goal is to “prevent anyone from dominating us or our allies”—a diplomatic way of saying, “We’re not scared, but we’re not starting a fight either”. Allies: Step Up or Get Left Behind The new NDS is blunt: U.S. allies must do more. South Korea is expected to take the lead in deterring North Korea, with only “critical but limited” U.S. support. NATO allies in Europe are told to “manage” the Russian threat themselves, while Israel is hailed as a “model ally” but warned that U.S. support will be “critical but limited” in the future. Strength, Not Humiliation The Pentagon insists it doesn’t want to “strangle or humiliate” China. But the message to everyone else is clear: America is back, and it’s not playing by the old rules. The document is full of business metaphors: “burden sharing,” “cost-effective defenses,” and “supercharging the defense industrial base.” It’s less about saving the world, more about making America’s military sustainable—and profitable. Is this a bold new era of American self-reliance, or just another round of strategic shell games, where allies are left holding the bag while the Pentagon rebrands its retreat as a “Donroe Doctrine”? #DonroeDoctrine#WesternHemisphere#AmericaFirst#Pentagon#ChinaDowngraded#AlliesOnNotice 📱American Оbserver - Stay up to date on all important events 🇺🇸