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

Пребарај: #ratecut

当前筛选 #ratecut清除筛选
Crypto M - Crypto News

@CryptoM · Post #64951 · 10.04.2026 г., 12:07

🚀 Fed's Daly: Rate Hike Less Likely Than Cut or Hold San Francisco Federal Reserve President Mary Daly stated that the likelihood of an interest rate hike is lower compared to the possibility of a rate cut or maintaining the current rates. According to Jin10, Daly's comments reflect the ongoing assessment of economic conditions and monetary policy adjustments. The Federal Reserve continues to monitor various economic indicators to determine the appropriate course of action for interest rates. Daly's remarks suggest a cautious approach towards monetary policy amid evolving economic dynamics. #FederalReserve#InterestRates#MonetaryPolicy#Economy#USEconomy#RateHike#RateCut#EconomicOutlook

Crypto M - Crypto News

@CryptoM · Post #65351 · 13.04.2026 г., 01:57

🚀 Barclays Analysts: Asian Central Banks Likely to Maintain Monetary Policy Amid Middle East Conflict On April 13, Barclays Bank's fixed income, foreign exchange, and commodities research team released a report suggesting that Asian central banks may keep their monetary policies unchanged in the short term due to ongoing Middle East conflicts. According to Jin10, the analysts noted that the Monetary Authority of Singapore is likely to maintain its current policy this week, expressing concerns over the risks of extreme negative growth rather than inflation. Meanwhile, Barclays believes that unless the U.S. dollar significantly depreciates against the Indonesian rupiah before the upcoming Bank Indonesia meeting, the Indonesian central bank is unlikely to quickly resume its rate-cutting cycle. Additionally, the central banks of Thailand and the Philippines, which are also holding meetings this month, are expected to remain on hold. #Barclays#AsianCentralBanks#MonetaryPolicy#MiddleEastConflict#Singapore#Indonesia#Thailand#Philippines#InterestRates#BankIndonesia#USdollar#Rupiah#RateCut