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

Резултати

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

Пребарај: #speed

当前筛选 #speed清除筛选
Interesting Planet 🌍

@interesting_planet_facts · Post #1189 · 03.01.2026 г., 22:11

🌎 The peregrine falcon holds the speed record for any animal on Earth. During hunting dives called “stoops,” it can reach over 320 kilometers per hour. This speed helps it catch birds in midair. ✨ #animals⚡#records⚡#speed 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #695 · 05.09.2025 г., 20:22

🌎 The cheetah is the fastest land animal, capable of sprinting up to 112 kilometers per hour for short distances. Its slender body and long tail provide balance while chasing prey across African plains. ✨ #animals⚡#speed⚡#records 👉subscribe Interesting Planet ​

Interesting Planet 🌍

@interesting_planet_facts · Post #589 · 19.08.2025 г., 16:22

🌎 Some bamboo species can grow up to 91 centimeters in a single day, making bamboo one of the fastest-growing plants on Earth. This rapid growth helps bamboo quickly regenerate after being harvested and provides vital habitats for many animals. ✨ #botany⚡#speed⚡#ecosystems 👉subscribe Interesting Planet

Universe Mysteries 🪐

@cosmomyst · Post #222 · 04.09.2025 г., 20:11

🪐 The pulsar PSR J1748−2446ad in the globular cluster Terzan 5 holds the record as the fastest-spinning known pulsar, rotating an astonishing 716 times per second. Pulsars are ultra-dense neutron stars that emit narrow beams of radiation, and this particular cosmic beacon spins so rapidly that its surface moves at about a quarter of the speed of light. ✨ #pulsars⚡#neutronstars⚡#speed⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries ​

Interesting Planet 🌍

@interesting_planet_facts · Post #524 · 08.08.2025 г., 20:22

🌎 Lightning-fast, the peregrine falcon dives at up to 320 km/h, making it the fastest animal on Earth. Specialized nostrils and strong muscles let it hunt mid-air with pinpoint accuracy. ✨ #falcon⚡#speed⚡#wildlife 👉subscribe Interesting Planet

ПретходнаСтраница 1 од 3Следна