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

Резултати

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

Пребарај: #navaloperations

当前筛选 #navaloperations清除筛选
Crypto M - Crypto News

@CryptoM · Post #65150 · 11.04.2026 г., 12:55

🚀 U.S. Navy Ships Navigate Hormuz Strait Without Coordination with Iran On April 11, U.S. officials announced that several U.S. Navy vessels traversed the Strait of Hormuz on Saturday. According to BlockBeats, the passage was conducted without coordination with Iranian authorities. The Strait of Hormuz is a strategic waterway, and such movements often draw international attention due to the geopolitical tensions in the region. #USNavy#HormuzStrait#Iran#Geopolitics#NavalOperations#InternationalRelations#MiddleEast

Crypto M - Crypto News

@CryptoM · Post #65296 · 12.04.2026 г., 15:20

🚀 Iran Intercepts U.S. Warships Near Strait of Hormuz Iran's navy reported intercepting two U.S. warships near the Strait of Hormuz as they attempted to enter the Persian Gulf during a ceasefire. According to NS3.AI, the vessels were identified as the Frank E. Petersen and Michael Murphy. Iran alleged that the ships aimed to project an image of a successful passage and potentially influence ongoing negotiations between the U.S. and Iran. #Iran#USNavy#StraitOfHormuz#Military#NavalOperations#PersianGulf#Geopolitics#InternationalRelations

Crypto M - Crypto News

@CryptoM · Post #65096 · 11.04.2026 г., 00:45

🚀 Iran Faces Challenges in Reopening Hormuz Strait Due to Unlocated Mines Iran is encountering difficulties in fully reopening the Strait of Hormuz as it struggles to locate all the mines it previously deployed. According to Odaily, the country also lacks the necessary capabilities to effectively clear these mines. This situation poses significant challenges for Iran in ensuring the safe passage of vessels through this critical waterway. #Iran#HormuzStrait#Mines#MaritimeSafety#Shipping#NavalOperations#InternationalTrade#Geopolitics

Crypto M - Crypto News

@CryptoM · Post #65313 · 12.04.2026 г., 22:02

🚀 CENTCOM to Enforce Blockade on Iranian Maritime Traffic CENTCOM has announced a blockade on all maritime traffic entering and leaving Iranian ports, effective April 13 at 10 a.m. ET. According to NS3.AI, this directive applies to vessels of any flag or ownership within Iranian coastal waters, including ports in the Arabian Gulf and the Gulf of Oman. Ships transiting the Strait of Hormuz to or from non-Iranian ports will maintain freedom of navigation. CENTCOM has not specified the duration of the blockade and stated that further guidance will be provided. #CENTCOM#Iran#Maritime#Blockade#StraitOfHormuz#ArabianGulf#GulfOfOman#NavalOperations

Crypto M - Crypto News

@CryptoM · Post #65342 · 13.04.2026 г., 00:52

🚀 UK Declines Participation in US Strait of Hormuz Blockade Informed sources have revealed that the United Kingdom will not join the United States in a blockade operation in the Strait of Hormuz, following an announcement by U.S. President Donald Trump that the US Navy would block the waterway. According to NS3.AI, a UK government spokesperson emphasized the country's commitment to freedom of navigation and stated that the UK is collaborating with France and other partners to form a coalition aimed at safeguarding the route. #UK#US#StraitOfHormuz#Blockade#NavalOperations#FreedomOfNavigation#InternationalRelations#Coalition#MaritimeSecurity