@shikoshikochannel · Post #3820 · 09.07.2025 г., 12:36
#cygnus
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #402 · 22 дек.
Отдельно разберём TaskGroup, который пришел на замену gather в Python 3.11. Ключевые отличия ▫️create_task() возвращает объект asyncio.Task, у которого есть соответствюущие методы управления. То есть у нас больше контроля ▫️это контекстный менеджер, который гарантирует что все таски будут остановлены по выходу из контекста ▫️ошибка автоматически отменяет незавершенные задачи, ▫️except* передает нам ExceptionGroup, в котором каждую ошибку можно обработать отдельно import asyncio import random async def do_it() -> str: if random.random() < 0.1: raise ValueError('Oops') delay = random.uniform(0.5, 1.5) await asyncio.sleep(delay) return delay async def main(): try: async with asyncio.TaskGroup() as tg: for _ in range(10): tasks.append(tg.create_task(do_it())) for t in tasks: print(t.result()) except *ValueError as e: for err in e.exceptions: print(err) asyncio.run(main()) Рекомендую изучить страницу Coroutines and Tasks из документации, где представлено больше интересных примеров и механизмов - таймауты - отмена задач - создание задач из другого потока #async
Hashtags
Пребарај: #cygnus
@shikoshikochannel · Post #3820 · 09.07.2025 г., 12:36
#cygnus
Hashtags
@cosmomyst · Post #3 · 29.07.2025 г., 14:41
🌎 Deep within the constellation Cygnus, the black hole V404 Cygni occasionally unleashes powerful outbursts, ejecting matter at near light-speed in opposing jets. These rare events are so energetic that the black hole briefly outshines its entire host galaxy, offering a fleeting glimpse into the turbulent ballet around stellar remnants. ✨ #blackhole⚡#cygnus⚡#jets 👉subscribe Universe Mysteries
Hashtags
@cosmomyst · Post #279 · 16.09.2025 г., 03:11
🪐 The black hole Cygnus X-1, in the constellation Cygnus, is famous for its powerful X-ray emissions and was one of the first strong black hole candidates ever discovered. Cygnus X-1 pulls material from a massive companion star, creating a swirling disk of superheated gas called an accretion disk, which emits intense X-rays as matter spirals inward toward the point of no return. ✨ #blackholes⚡#accretiondisks⚡#cygnus⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries