TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

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

Резултати

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

Пребарај: #happyfappy

当前筛选 #happyfappy清除筛选
PT风向旗

@Ptfxq · Post #608 · 09.03.2024 г., 07:12

#AR#站点免费#站点公告 Hey guys, As you can see, we're back on track but still working on some issues. Bear with us as we iron these things out. Global Freeleech will be ending on Monday. Thanks Edit: If you have the means to be a racer, please contact phiend ———— #HappyFappy#站点免费 因为 38 妇女节,站免两天。还剩 1 day, 16 hours。 ———— #HeBits#站点免费#开放注册#综合公告 HeBits 迎来了它的 16 岁生日,开注、站免 5 天,在这期间每天还可以领取一份每日礼物。 ———— #PTP#站点公告 Just wanted to put out a quick message to let everyone know we're going to be addressing some lingering IRC issues in the next few days, and in the meantime IRC is down while we sort them out. We're also aware of some site features (I.E. IMDB not pulling properly) not working properly, these will addressed very shortly. Edit: They're fixed! Let us know if anyone runs into any lingering isues. We apologize for the inconveniences, we hope to have everything sorted out by the end of the weekend at the earliest.