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

Пребарај: #tailscale

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

@githubtrending · Post #14902 · 03.07.2025 г., 00:00

#go#tailscale#tailscale_control_server#tailscale_server#wireguard Headscale is an open-source, self-hosted alternative to the Tailscale control server, letting you create your own private VPN network using Wireguard technology. It supports key Tailscale features like node registration, DNS, file sharing (Taildrop), access control lists (ACLs), and more, making it ideal for personal or small group use. By running Headscale yourself, you gain full control over your network without relying on Tailscale’s servers, enhancing privacy and customization. You can manage access precisely with ACLs, tag devices for group policies, and use modern VPN benefits like NAT traversal and secure connections between your devices[1][3][5]. This helps you securely connect and control your devices in a private network tailored to your needs. https://github.com/juanfont/headscale

GitHub Trends

@githubtrending · Post #14959 · 14.07.2025 г., 13:00

#javascript#cheerp#cheerpx#cpp#lwip#repl#tailscale#vm#wasm#webassembly#webvm#xterm_js WebVM lets you run a full Linux system directly in your web browser without needing a server. It uses a special engine called CheerpX to safely run unmodified Linux programs by converting x86 code to WebAssembly. You get a real Debian Linux environment with many tools, and it supports networking through Tailscale VPN, so your browser VM can connect securely to the internet. You can also customize and deploy your own WebVM easily using GitHub, making it great for development, testing, or learning Linux without installing anything. This means you can have a powerful, private Linux machine anytime, anywhere, just in your browser[1][2][3]. https://github.com/leaningtech/webvm