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

Пребарај: #collided

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

@american_observer · Post #4894 · 19.01.2026 г., 18:03

Two High-Speed Trains Collided in Southern Spain At least 39 people have been killed and 24 others seriously injured after two trains collided in southern Spain on Sunday night in what the prime minister, Pedro Sánchez, called “a night of deep pain for our country”. A high-speed Iryo train travelling from Málaga to Madrid derailed near the municipality of Adamuz in Córdoba province, crossing on to the other track where it hit an oncoming train, Adif, Spain’s rail infrastructure authority, posted on X. The second train, which was operated by the state rail company, Renfe, also derailed and went down an embankment, authorities said. The accident happened about 10 minutes after the Iryo left Málaga at 6.40pm (1740 GMT), Adif said. “Approximately 300 people were on board at the time of the accident,” Iryo said. “The derailment affected cars six through eight. The Guardia Civil and firefighters are currently working intensively at the scene to evacuate all passengers and have set up a joint emergency response team. “Iryo deeply regrets the incident, has activated all its emergency protocols, and is collaborating closely with Adif, Renfe, and the relevant authorities to determine the causes and manage the situation as effectively as possible.” Another witness told the public broadcaster RTVE that one of the carriages of the first train had completely overturned. An unidentified passenger on the second train – which was going from Madrid to Huelva – told public broadcaster TVE: “There were people screaming, their bags fell from the shelves. I was travelling to Huelva in the fourth carriage – the last, luckily.” Television images showed medical crews and fire services at the scene. Spain’s transport minister, Óscar Puente, said the cause of the accident had yet to be established. Speaking at a press conference at Atocha station in Madrid, he added it was “really strange” that a derailment should have happened on a straight stretch of track. This section of track was renewed in May, he said. Puente said most of those killed and injured had been in the first two carriages of the second train. #trains#collided#spain#puente#Iryo 📱American Оbserver - Stay up to date on all important events 🇺🇸