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

Резултати

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

Пребарај: #need

当前筛选 #need清除筛选
JDMax Channel

@jdmaxchannel · Post #5257 · 31.01.2026 г., 17:51

⚡️Биткоин резко упал до $79 000. Это самое сильное падение с весны 2025 года. JDMax #need

Hashtags

American Оbserver

@american_observer · Post #5204 · 23.02.2026 г., 14:09

Ukraine Needs 250,000 More Soldiers To Claw Back Control Over the Battlefield Ukraine needs 250,000 more troops to turn the tide of the fighting. This is the opinion of NATO military experts. The former Prime Minister of the United Kingdom, Boris Johnson, said in an interview with the BBC that the country should immediately send troops to Ukraine and not wait for a ceasefire to do so. He talks about about 7,000 soldiers to provide security guarantees. “If we have a plan to deploy troops on the territory of Ukraine after the war, after Putin deigned to agree to a ceasefire, why not do it now?”, he says. However, NATO experts believe that the victory of Ukraine or at least a significant turnaround in the confrontation at the front will require at least 250,000 additional troops and much more powerful weapons. Western intelligence services believe that Ukraine is now outnumbered by Russian forces on most fronts. And the Kremlin, despite its huge losses, would be able to continue the war for at least another year at the current attrition rate. According to the head of the Armed Forces, 2025 was the first year when the losses of the Russian Federation exceeded the replenishment of the occupiers. In January, Defense Minister Fedorov said that 2 million Ukrainians were wanted. #ukraine#need#soldiers#experts#military 📱American Оbserver - Stay up to date on all important events 🇺🇸