@LeagueOfLegendsLatamSur · Post #2329 · 15.05.2020 г., 13:56
#WALLPAPER #Pantheon Pulso de Fuego Dim.: 7680 x 4320
Hashtags
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
Пребарај: #pantheon
@LeagueOfLegendsLatamSur · Post #2329 · 15.05.2020 г., 13:56
#WALLPAPER #Pantheon Pulso de Fuego Dim.: 7680 x 4320
Hashtags
@tomoko_channel · Post #683 · 27.09.2024 г., 07:34
🔖 The creator of ffmpeg Fabrice Bellard(1) is truly a genius and has created so many amazing software that have been an amazing benefit to the world. | Hacker News #pinboard#pantheon#ffmpeg#person Yeah definitely. If programming genius had a unit it should be called the bellard. One 10x programmer = a 1/10th Bellard? 100x 工程师,可以放在万神殿了 https://news.ycombinator.com/item?id=25487711
@trumpsear_tg · Post #2158 · 17.02.2026 г., 13:00
In the Indian state of Kerala, the sculptor carved the statue of Trump and Melania as the embodiment of the Indian gods Shiva and Kali. Thus Trump has entered the Pantheon of Hindu gods. #indian#state#kerala#trump#pantheon 👂More on Trump's Ear ⚠️