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 слични објави

Пребарај: #audiq5

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

@revheadcrypto · Post #423 · 02.09.2024 г., 13:52

▎🚘 Introducing the All-New Audi Q5! The next generation of the Q5 has arrived, now built on the PPC (Premium Platform Combustion), shared with the recently unveiled Audi A5. The design is completely new, yet resonates with the familiar aesthetic of Audi’s electric models. 🎮Inside the Cabin: Featuring three stunning displays on the central panel, the media system runs on Android OS. The compact gear selector enhances the sleek design, while physical climate control buttons have been eliminated for a more modern feel. ⚡️Power & Performance: In Europe, all Audi Q5 engines will come equipped with the MHEV Plus mild-hybrid system, featuring a 24 hp electric motor and a compact battery. The base versions will offer both petrol and diesel engines with a 2.0-liter capacity, delivering 204 hp (340 Nm) and 204 hp (400 Nm), paired with a seven-speed dual-clutch transmission. The powerful 3.0-liter V6 in the Audi SQ5 boasts an impressive 376 hp and 550 Nm of torque. 🗓️Availability: The new Q5 will hit European markets in Q1 2025, with pre-orders already open, starting from €52,300 to €82,900. ▎🔥 Get ready to experience luxury like never before! #AudiQ5#NewGeneration#LuxurySUV#Audi#Innovation#MHEV#Auto