@verse · Post #108 · 20.07.2024 г., 12:58
Cycling alone Past Andrew Wyeth fields – No lid on the world! #haiku by MR
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
Пребарај: #haiku
@verse · Post #108 · 20.07.2024 г., 12:58
Cycling alone Past Andrew Wyeth fields – No lid on the world! #haiku by MR
Hashtags
@PensivePost · Post #5246 · 31.05.2021 г., 07:56
Relationship. On a lonely night, Two strangers bumped into eachother. And a relationship bloomed. #review#haiku
@QuietWorld · Post #6840 · 31.10.2019 г., 23:30
🔖Haiku 🌸“To sleep on our thoughts, Is better than to lose sleep over rash actions” #haiku#life#wisdom @quietworld🍃
@QuietWorld · Post #6766 · 22.10.2019 г., 13:01
🔖Haiku 🌸“When cherry blossoms scatter, no regrets.” .·. even when the cherry blossoms live for only a short period of time, they fall to their death with no regrets – because they offered beauty and loveliness around them. #haiku#life#kindness @quietworld🍃
@PensivePost · Post #5276 · 05.06.2021 г., 14:33
Mind had no more muse The poet in me, died and rot And my haiku cried. #review#haiku#nandini
@PensivePost · Post #5713 · 06.05.2022 г., 13:01
#review#iam#haiku Is this the demise of the unique journey?? If yes!!! Then what else is there in our stores?? Sounds meaningless!!!
@PensivePost · Post #5309 · 18.06.2021 г., 11:16
Haiku Sunshine after rain, Droplets on the spider web Glisten on and off. #review#haiku#Florence
@PensivePost · Post #5300 · 16.06.2021 г., 06:16
Haiku The storm raged outside Frightening the little blue birds And rain fell sideways. #haiku#review#Florence
@PensivePost · Post #5296 · 15.06.2021 г., 07:09
Haiku Look at the prim rose Rain-soaked, wind-kissed and enticed Emanating joy! #haiku#review#Florence
@PensivePost · Post #5275 · 05.06.2021 г., 13:52
Haiku Flowers in garden Basking in the petrichor Sway in balmy wind. #review#haiku#Florence
@PensivePost · Post #5247 · 31.05.2021 г., 17:15
Haiku Dark grey clouds gathered, A drop of rain on my nose Eruption of joy! #review#haiku#Florence
@PensivePost · Post #5236 · 29.05.2021 г., 13:33
HaikuHaiku A blooming red rose With raindrops like pearls Blushes like a bride. #review#haiku#Florence