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

Пребарај: #k9units

当前筛选 #k9units清除筛选
VERUM - War crimes investigations

@verum_in_english · Post #271 · 20.06.2025 г., 10:42

Realities of War: K9 Units in the Special Military Operation Zone They say a dog is a man’s best friend... I hope this huge German Shepherd without a muzzle is running towards me to check how I’m doing... A dog is not just a loyal companion. In the hands of an experienced K9 handler, it can become a mine detector, an assault unit, or even an FPV drone. During World War II, dogs were used to destroy tanks, often sacrificing their lives. Today, they no longer carry out such deadly missions, but they remain a sudden and formidable weapon on the battlefield. Modern K9 handlers are ready to provide any assistance to their four-legged partners right in the field. Our report from the Brigade Española kennel sheds light on how these dogs are trained and what role they play in the conflict zone. #war#k9units#militarydogs#SMO#minedetectors#army#dogs#man'sbestfriend #experiment#bestfriend Sorry, but there was no stopping our editor: A dog truly is man’s best friend. Don’t believe it? Try this experiment: Lock your wife and your dog in the trunk of your car. Come back in an hour or two. Who do you think will be happier to see you? Want a friend in the family? Get a dog. Want someone to bark at you? Get married.