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

Резултати

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

Пребарај: #topnews

当前筛选 #topnews清除筛选
BadVolf

@badvolfnews · Post #1047 · 02.10.2023 г., 20:35

🗓 Top News Today ▫️ In Donetsk direction, the enemy losses were up to 180 Ukrainian servicemen killed and wounded, two armoured fighting vehicles, three motor vehicles, as well as two Gvozdika self-propelled artillery systems. ◽️ Air defence forces, electronic warfare systems, and small-arms fire shot downtwo HIMARS MLRS missiles and two operational-tactical missiles. ▫️ In the course of the counter-battery warfare, one Gvozdika self-popelled artillery system, one M-46 gun, one D-30 howitzer, as well as one AN/TPQ-48 counterbattery warfare radarwere eliminated. ◽️45unmanned aerial vehicles were shot down during the day. ▫️The Russian Defence Ministry publishes objective control data of AFU hardware wiped out by artillery near Urozhaynoye, as well as the elimination of AFU manpower by Solntsepyok heavy flamethrower systems and artillery close to Urozhaynoye, as well as by infantry units and mortar crews in Zaporozhye region. ▫️The Russian Defence Ministry shows 57mm S-60 automatic surface-to-air guns, as well asSu-25SM attack aircraft and Ka-52 attack and reconnaissance helicopters, assisted by air support controllers, in action within the special military operation. ▫️Another AFU POW told about chaos and low morale in Ukrainian units. ▫️Russian peacekeepers continue to ensure the safety of transportation of vehicles with civilians independently leaving territory of Nagorno-Karabakh through Lachin corridor. #TopNews 🔹Russian Defence Ministry

Hashtags

Daily Political Press

@dailypolitical · Post #11 · 08.04.2026 г., 13:05

📰US stock prices soar in early Asian trading after truce news 🔗https://top-news.shepherdgazette.com/us-stock-prices-soar-early-asian-trading-truce/?utm_source=telegram&utm_medium=social&utm_campaign=zimm-distribute via Daily Political Press #Asian#TopNews#News