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

Пребарај: #openapi3

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

@githubtrending · Post #14735 · 22.05.2025 г., 11:30

#javascript#api_client#api_testing#automation#developer_tools#git#graphql_client#http_client#javascript#openapi#openapi3#opensource#rest_api#testing#testing_tools Bruno is a free, open-source API testing tool that stores your API collections as plain text files on your device, ensuring your data stays private without cloud syncing. It works across Mac, Windows, and Linux, and supports collaboration through Git or any version control system, making teamwork easier. Bruno automates API testing with JavaScript scripts, increasing efficiency, test coverage, and simplifying integration into CI/CD pipelines. This helps catch bugs early, maintain tests easily, and run regression tests smoothly, saving you time and improving API reliability compared to traditional tools like Postman. You can download it easily via multiple package managers. https://github.com/usebruno/bruno

GitHub Trends

@githubtrending · Post #14911 · 03.07.2025 г., 15:30

#javascript#hacktoberfest#oas#open_source#openapi#openapi_specification#openapi3#openapi31#rest#rest_api#swagger#swagger_api#swagger_js#swagger_oss#swagger_ui Swagger UI is a tool that helps developers and users interact with APIs. It creates a visual interface from OpenAPI specifications, making it easy to understand and use APIs without needing to know the underlying code. This tool benefits users by providing clear documentation and allowing them to test API methods directly from the interface. It also supports collaboration and compliance with the latest OpenAPI standards, making it easier to develop and consume APIs efficiently[1][3][5]. https://github.com/swagger-api/swagger-ui

GitHub Trends

@githubtrending · Post #14761 · 29.05.2025 г., 13:00

#python#api#async#asyncio#fastapi#framework#json#json_schema#openapi#openapi3#pydantic#python#python_types#python3#redoc#rest#starlette#swagger#swagger_ui#uvicorn#web FastAPI is a modern Python web framework for building fast, reliable APIs that is easy to learn and quick to code, making it ready for production use right away. It uses standard Python type hints, which means you get automatic data validation, fewer bugs, and great editor support with code completion and type checks. FastAPI also generates interactive documentation automatically, so you and your team can understand and test your API easily. The main benefit is that you can develop robust, high-performance APIs much faster and with less effort, while reducing errors and making your code easier to maintain[1][2][3]. https://github.com/fastapi/fastapi