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

Резултати

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

Пребарај: #intergalactic

当前筛选 #intergalactic清除筛选
Universe Mysteries 🪐

@cosmomyst · Post #529 · 30.11.2025 г., 12:21

🪐 The light from the Triangulum Galaxy (Messier 33), our next-nearest spiral neighbor, takes about 2.7 million years to reach Earth—meaning we see this galaxy as it was millions of years ago. Even within the Local Group of galaxies, the vast stretches of intergalactic space are so immense that a beam of light travels these cosmic distances only after crossing generations of life on our planet. ✨ #spacedistances⚡#triangulumgalaxy⚡#intergalactic⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​

Universe Mysteries 🪐

@cosmomyst · Post #386 · 07.10.2025 г., 12:21

🪐 In 2024, observations with the CHIME radio telescope revealed that some fast radio bursts (FRBs) can travel through the sparse gas between galaxies—known as the intergalactic medium—without slowing down or scattering as much as expected. This suggests that the space between galaxies, like that between the Milky Way and the Triangulum Galaxy (M33), is even more empty and calm than scientists previously thought, allowing these intense millisecond bursts of radio energy to arrive at Earth almost untouched by cosmic matter. ✨ #FRB⚡#radioastronomy⚡#intergalactic⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​

Universe Mysteries 🪐

@cosmomyst · Post #34 · 30.07.2025 г., 05:51

🪐 The Andromeda Galaxy, our colossal neighbor, is surrounded by an immense, nearly invisible halo of hot gas that spans more than 1.3 million light-years across. Recent observations with the Hubble Space Telescope revealed that this vast envelope is rich in metals and may be interacting with our own Milky Way’s halo, weaving an intergalactic veil between the two future-colliding giants. ✨ #Andromeda⚡#galactic⚡#halos⚡#intergalactic 👉subscribe Universe Mysteries