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

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #401 · 15 дек.

Функция asyncio.wait() это еще один способ вызвать множество асинхронных задач. Она работает в нескольких режимах. 1. Самый простой - ждем завершения всех задач async def main(): tasks = [asyncio.create_task(do_it(i)) for i in range(10)] done, pending = await asyncio.wait( tasks, return_when=asyncio.ALL_COMPLETED ) for task in done: try: print(task.result()) except Exception as e: print(e) Очень похоже на gather, но работает не так. ▫️возвращает не результаты, а два сета с объектами Task у которых можно забрать результат через task.result() если они в списке done ▫️не гарантирует порядок результатов так как оба объекта это set ▫️не выбрасывает исключение когда оно появляется, а сохраняет его в Task. Исключение появится когда попробуете забрать резултьтат. 2. Ждем завершения первой задачи, даже если там ошибка. async def main(): tasks = [asyncio.create_task(do_it(i)) for i in range(3)] done, pending = await asyncio.wait( tasks, return_when=asyncio.FIRST_COMPLETED ) # в done может быть несколько задач! for task in done: try: print(task.result()) except Exception as e: print(f"Fail: {e}") # Оставшиеся задачи в pending, как правило, нужно отменить, иначе они будут продолжать работать for task in pending: task.cancel() В сете done будут таски которые успели завершится, причем как успешно так и нет. 3. До первой ошибки. Тоже самое, но с аргументом FIRST_EXCEPTION done, pending = await asyncio.wait( tasks, return_when=asyncio.FIRST_EXCEPTION ) Функция завершается как только первая задача упадет с ошибкой. Учтите, что в любом случае done вы можете обранужить несколько задач, как с ошибками так и успешные. ↗️ Полный листинг примеров здесь #async

Hashtags

Резултати

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

Пребарај: #bespoke

当前筛选 #bespoke清除筛选
Car News

@car_news · Post #766 · 19.11.2024 г., 10:55

🚘 has unveiled a Phantom Goldfinger car with a hidden gold bar in the cabin 🎂 The sedan was created for the 60th anniversary of Goldfinger – a film about James Bond. In the film, a millionaire criminal smuggles gold. He smelts gold and makes it into parts for his Rolls-Royce Phantom. 🔎 The modern Phantom received a golden-black body paint, repeating the colour scheme of the car from the film, and many other references to the film. For example, the signature nose piece ‘Spirit of Ecstasy’ looks as if it was made of pure gold, which for disguise was covered with silver, partially erased. In fact, the opposite is true: the mascot was made of silver and plated with an uneven coating of 18-carat gold. @CarsNews #RollsRoyce#Bespoke#restyling

Auto Life

@revheadcrypto · Post #564 · 10.10.2024 г., 09:50

✨ Introducing the Rolls-Royce Ghost Series II ✨ The updated sedan features a stunning new headlight design and an enlarged grille, reminiscent of the Spectre coupe! 🚗💎 The 22-inch wheels showcase fresh patterns, and a new deep blue shade joins the color palette. 🎨🔵 Inside, experience luxury with a unique bamboo-based fabric, crafted over a year! 🌿🛋️ The media system now operates on the advanced Spirit OS. 📱🎶 Under the hood, the powerful turbocharged V12 engine boasts 563 hp (591 hp in the Black Badge version) and is paired with an 8-speed automatic transmission for smooth rear-wheel drive. 💨⚙️ Elevate your journey with the Ghost Series II! 🌌 #RollsRoyce#GhostSeriesII#Luxury#AutomotiveExcellence#V12Power#Bespoke#EleganceOnWheels#Auto