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

Резултати

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

Пребарај: #x64

当前筛选 #x64清除筛选
GitHub Trends

@githubtrending · Post #15431 · 23.01.2026 г., 13:30

#cplusplus#3d_engine#arm64#cmake#cplusplus#cpp17#d3d11#directx#directx11#engine#game#game_engine#gamedev#mod#opengl#opensource#sdl#sdl2#stalker#x64#xray_engine OpenXRay is a free, improved version of the X-Ray Engine for S.T.A.L.K.E.R. games like Call of Pripyat and Clear Sky. It adds 64-bit support, higher FPS, bug fixes, modding tools, and runs on Linux, macOS, and more. This benefits you with smoother, more stable gameplay, better performance on modern or non-Windows PCs, and easy access to new mods without changing the classic feel. https://github.com/OpenXRay/xray-16

GitHub Trends

@githubtrending · Post #15612 · 12.04.2026 г., 11:30

#c_lang#aarch64#arm#arm64#bios#boot_loader#boot_manager#bootloader#efi#gpt#loongarch#loongarch64#loongson#mbr#risc_v#riscv#riscv64#uefi#x64#x86#x86_64 Limine is a modern bootloader that boots Linux and other OSes on x86, ARM64, RISC-V, and LoongArch64 hardware, supporting MBR/GPT partitions and FAT/ISO filesystems on 32-bit Pentium Pro+ or 64-bit systems. Get binaries via Git (e.g., `git clone --branch=v11.x-binary`), build tools with `make`, and join Matrix/Fluxer chats for help. This lets you easily manage and boot multiple OSes with a clean menu, saving time on custom PC or server setups. https://github.com/Limine-Bootloader/Limine