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

Резултати

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

Пребарај: #usearnings

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

@CryptoM · Post #64598 · 09.04.2026 г., 09:55

🚀 STOCKS | BlackRock CIO Warns of Potential Downgrade in Stock Earnings Due to Middle East Conflict Helen Jewell, BlackRock's International Chief Investment Officer for Fundamental Equities, has indicated that the ongoing Middle East conflict could necessitate a reduction in stock earnings expectations. According to Jin10, Jewell noted that current earnings forecasts for this year remain high, ranging from 15% to 18%, suggesting significant room for downward adjustments. She expressed skepticism about the stability of earnings predictions in the consumer sector, particularly given the impact of interest rates and inflation stemming from the Middle East situation. Preliminary signs indicate potential changes in earnings expectations. After weeks of analysts raising forecasts, Citigroup's U.S. Earnings Momentum Index turned negative last Friday, with downgrades outnumbering upgrades by the largest margin in nearly a year. Despite this, analysts' predictions remain optimistic amid high uncertainty and rising price pressures. Compiled data shows that the market generally expects the S&P 500's earnings per share to grow by 16% this year, marking the strongest performance since 2021. The first-quarter earnings season is set to officially begin next week. Jewell highlighted that the potential for earnings growth in energy and materials stocks is offset by the downside risks in industries such as aviation, suggesting that overall earnings will remain relatively stable. #stocks#BlackRock#MiddleEastConflict#earningsforecast#consumersector#interestrates#inflation#Citigroup#USearnings#S&P500 #energy#materials#aviation#investment