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

Резултати

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

Пребарај: #institution

当前筛选 #institution清除筛选
Borkena

@borkena · Post #5458 · 05.12.2025 г., 05:15

The Co-optation of Continental Institutions: Abiy Ahmed’s Faustian Bargain with IGAD and the AU, and Its Inevitable Backfire on Ethiopian Stability. Read more. https://borkena.com/2025/12/04/the-co-optation-of-continental-institutions-abiy-ahmeds-faustian-bargain-with-igad-and-the-au-and-its-inevitable-backfire-on-ethiopian-stability/#Ethiopia#politics#Africa#Institution

📊Sanksiyani bartaraf etish, mintaqaviy integratsiya va institutlar 🟣Oliy maktabda Qozog‘iston Respublikasining Narxoz Universiteti professori Murat Issabayev ishtirokida “Sanksiyani bartaraf etish, mintaqaviy integratsiya va institutlar” mavzusidagiilmiy seminar bo‘lib o‘tdi. 💬Sanction Mitigation, Regional Integration, and the Role of Institutions 🟣The Graduate School hosted a scientific seminar titled "Sanctions Mitigation, Regional Integration, and Institutions," featuring Professor Murat Issabayev from Narxoz University, Kazakhstan. 🏙Устранение санкций, региональная интеграция и институты 🔴В Высшей школе состоялся научный семинарна тему «Устранение санкций, региональная интеграция и институты» с участием профессора Нархозского университета Республики Казахстан Мурата Иссабаева. #GraduateSchool#Sanction#Integration#Institution 🔝Web-site |🔝Facebook | 🔝Instagram | 🔝Youtube

Venture Village Wall 🦄

@venturevillagewall · Post #3703 · 24.12.2024 г., 14:37

Fed's Role in Bitcoin Reserve Plans Discussions arise on the establishment of a Bitcoin Strategic Reserve (BSR) if Trump decides to act quickly. The U.S. Treasury could use the Exchange Stabilization Fund to purchase Bitcoin via an executive order. Long-term stability requires congressional legislation to include Bitcoin in the Strategic Reserve Act. Both steps are Treasury-led, firmly placing the Federal Reserve outside of this decision-making process. In another noteworthy development, blockchain project Trrue has secured a $10 million investment commitment from GEM Digital, despite GEM's background of fraudulent activity, raising concerns over transparency in reporting. Read more: Wu Blockchain News | CoinDesk | Wu Blockchain News #Fed#Bitcoin#BSR#UStreasury#ExecutiveOrder#Trrue#Investment#GEMDigital#Fraud#Blockchain#Transparency#Congress#ReserveAct#Crypto#Finance#News#Regulation#Market#Tokens#Ecosystem#Institution