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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #425 · 20 апр.

Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках. Выглядело это примерно так: from fastapi.concurrency import run_in_threadpool async def execute(data: DataRequest) -> DataResponse: try: result = await run_in_threadpool(sync_function, data) return DataResponse(data=result) except Exception as e: return DataResponse( error=str(e), success=False, ) В общем работает нормально. Для всех вызовов под капотом используется общий тредпул, всё работает предсказуемо. Но потребовалось изменить количество запускаемых в пуле потоков (по умолчанию создается 40 воркеров). Так как дело происходит с FastAPI, делается это через lifespan используя настройки anyio: import anyio @asynccontextmanager async def lifespan(app: FastAPI): limiter = anyio.to_thread.current_default_thread_limiter() limiter.total_tokens = 100 yield # если вдруг нужно вернуть обратно limiter.total_tokens = 40 Зачем менять количество воркеров? - уменьшить, если оперативки мало (один тред занимает ~8мб) - увеличить чтобы выдержать нагрузку Если есть предложения получше при тех же вводных - предлагайте😉 #async

Hashtags

Резултати

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

Пребарај: #convertible

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

@car_news · Post #618 · 09.10.2024 г., 17:35

🚘 has presented modernized coupe and convertible LC The model range, produced since 2017, got slightly modernized exterior and new interior materials, but at the same time received a more rigid body. Additional struts installed under the floor in the area of the front and rear axles should favorably affect the handling. The Lexus LC engine range consists of a five-liter V8 with 477 horsepower or a 3.5-liter V6-based hybrid unit with 359 hp. Starting from $107,625. @CarsNews #Lexus#hybrid#convertible

Auto Life

@revheadcrypto · Post #298 · 10.08.2024 г., 12:16

🚗✨ Exciting News from Mercedes-Maybach! ✨🚗 Get ready for the debut of the stunning new convertible on August 15th at the prestigious Pebble Beach! 🌊🏖️ The highly anticipated model has been teased since 2022, and we can't wait to see it in all its glory! 🤩 🔍 Fuel Efficiency: The Mercedes-Maybach SL boasts an impressive fuel consumption of 13.7 liters per 100 km*, closely matching the non-hybrid Mercedes-AMG SL 63 with its powerful 4.0L V8 engine, delivering a thrilling 585 hp and 800 Nm* of torque! 💨🔥 #MercedesMaybach#Convertible#LuxuryCars#PebbleBeach#CarDebut#FuelEfficiency#AMG#V8Power#Auto