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

Пребарај: #antd

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

@githubtrending · Post #15034 · 07.08.2025 г., 11:30

#javascript#antd#music#music_player#nodejs#react#react_router#redux#webapp#webpack Copper Bell is a free website app focused on listening to music. It offers many songs and has a simple, clean design that makes it easy to find and play your favorite music. You can search for songs, make playlists, read scrolling lyrics, save songs, and create your own song lists. It does not have live broadcasts, social features, or ads, so there are no distractions and you get a pure music experience. You can use it on any modern web browser without installing anything. It works on many devices, including tablets. This way, you can enjoy music, manage your songs, and discover new tunes easily anytime and anywhere. https://github.com/enzeberg/tonzhon-music

GitHub Trends

@githubtrending · Post #14894 · 02.07.2025 г., 11:30

#typescript#antd#antd_design#docker#go#golang#guacamole#rdp#react#ssh#vnc Next Terminal is a simple and secure system that lets you access and manage remote computers using protocols like RDP, SSH, VNC, Telnet, and HTTP. It is designed for businesses to record sessions, track audits, and help with compliance reporting, making IT management easier and safer. Using Next Terminal can improve security by monitoring remote access and help ensure your company meets regulatory requirements. It is user-friendly and supports multiple connection types, which saves time and effort in managing remote systems securely. Consulting your IT administrator before use is recommended for safe deployment. This tool benefits you by enhancing control and oversight of remote IT activities. https://github.com/dushixiang/next-terminal