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

Резултати

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

Пребарај: #uxlinkfams

当前筛选 #uxlinkfams清除筛选
UXLINK

@uxlink_community · Post #258 · 12.02.2025 г., 08:43

Dear #UXLINKfams, please join us during @consensus_hk, hosted by @meet_48 and powered by @BNBCHAIN❤️ Registration link: https://lu.ma/6c7oaehq

Hashtags

UXLINK

@uxlink_community · Post #225 · 29.01.2025 г., 01:59

Best wishes to all #UXLINKfams who are celebrating the Lunar New Year and Chinese New Year in this beautiful and reunion time: Happy New Year! LINK Family, LINK Happiness! 새해 복 많이 받으세요! あけましておめでとう! 新年快樂, 恭喜發財! CHÚC MỪNG NĂM MỚI! শুভ নববর্ষ! Selamat Tahun Baru! Manigong Bagong Taon! สวัสดีปีใหม่! Mutlu yıllar! Bonne année! ¡Feliz año nuevo! С Новым Годом!

Hashtags

UXLINK

@uxlink_community · Post #246 · 07.02.2025 г., 08:57

🫡Glad to be partnership with @AEON_Community, a leading #WEB3 payment protocol. $UXLINK will be supported by #AEON Pay and tens of millions #UXLINKfams could use their token to make in-store payment in real world in dozens of countries especially in South East Asia. UXLINK FujiPay/ FujiCard will also collab with AEON to build #PayFi ecosystem together and provides a seamless bridge between crypto assets and real-world applications, empowering users with secure, inclusive, and rewarding financial services. You can buy a pizza with your crypto assets by a simple swipe🥳.