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

Резултати

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

Пребарај: #cai

当前筛选 #cai清除筛选
AI & Law

@ai_and_law · Post #197 · 22.12.2023 г., 08:04

CAI Unveils Public "Zero Draft" for AI Framework Convention Greetings AI & Law community! The European Committee on Artificial Intelligence (CAI) has announced the public release of the revised "Zero Draft" Framework Convention on Artificial Intelligence, Human Rights, Democracy, and the Rule of Law. Key Points: 1️⃣ The "Zero Draft" serves as the foundational document for drafting the Framework Convention and is not the final outcome of CAI negotiations. 2️⃣ A Consolidated Working Draft has been prepared based on the first reading of the revised Zero Draft, containing preliminary agreements and proposals for further negotiations. 3️⃣ The text which is not in brackets and in red font is considered to be preliminarily agreed. 4️⃣ The CAI Bureau has decided to make this document public, providing transparency into the ongoing process. The recently released Draft Framework Convention, based on outcomes from the second reading, will be the focal point for the upcoming 9th Plenary meeting. Notably, provisions under negotiation include the Scope, Risk and impact management framework, and the Conference of the Parties. #AIlaw#CAI#AIregulation#FrameworkConvention#TransparencyInAI

GitHub Trends

@githubtrending · Post #15481 · 09.02.2026 г., 11:30

#go#actions#cai#ci#claude_code#codex#copilot#gh_extension#github_actions GitHub Agentic Workflows let you write simple markdown instructions in natural language to automate repo tasks like triaging issues, fixing CI failures, generating reports, and improving code—running safely as GitHub Actions with AI like Copilot or Claude. Strong guardrails ensure read-only access by default, sandboxed execution, and human-reviewed outputs via pull requests. This saves you time on repetitive work, boosts efficiency with adaptive AI decisions, and keeps everything secure without complex YAML coding. https://github.com/github/gh-aw