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

Резултати

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

Пребарај: #carnews

当前筛选 #carnews清除筛选
Auto Life

@revheadcrypto · Post #259 · 07.08.2024 г., 11:59

🚗✨ Exciting news from BMW! The new extended X3 is here, specially designed for the Chinese market! 🇨🇳 With a wheelbase stretched by 110 mm to an impressive 2975 mm (just like the European BMW X5), the overall length now reaches 4865 mm! 📏 Available in two versions: 25L and 30L, both equipped with an 8-speed automatic transmission and a powerful 2.0L turbo engine. Choose between 190 hp & 310 Nm or 258 hp & 400 Nm! 💪🔥 #BMW#X3#LuxurySUV#China#CarNews#Automotive#Innovation#Auto🚘🌟

Auto Life

@revheadcrypto · Post #394 · 27.08.2024 г., 14:13

🚗✨ Exciting news for Land Rover fans! The upcoming Discovery is set to embrace a more family-friendly design, possibly resembling a minivan! 🏡👨‍👩‍👧‍👦 As stated by Mark Cameron, this shift is aimed at boosting sales, especially with the Defender selling six times better in 2023. 📈💼 Stay tuned for the new generation expected in 2026! 🗓️🔄 #LandRover#Discovery#FamilyCar#MinivanStyle#CarNews#2026Release#Sports🌍🚙