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

Резултати

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

Пребарај: #hedera

当前筛选 #hedera清除筛选
Venture Village Wall 🦄

@venturevillagewall · Post #4347 · 09.03.2025 г., 16:00

Hedera's ETF Potential and Price Correction Hedera ($HBAR) emerges as a strong contender for a spot ETF in the USA, driven by its ecosystem development and high standards in security and transparency. Currently, it faces a correction after testing a resistance level at $0.260, now moving towards a support zone at $0.195. A sideways movement is anticipated in the coming weeks. BTC price aims for $84,000. Read more: Leviathan News #Hedera#ETF#Crypto#HBAR#Bitcoin#Investing#Markets#Regulations

Venture Village Wall 🦄

@venturevillagewall · Post #4033 · 30.01.2025 г., 22:00

Coinbase Lists Solana Futures with CFTC Coinbase Derivatives has filed with the CFTC to list Solana Futures, nano Solana Futures, and Hedera Futures, marking an expansion in their derivatives offerings for popular cryptocurrencies. For details, check the link: Coinbase Futures Filing. #Coinbase#Solana#Hedera#Futures#CFTC#Investing#Crypto#DeFi#Finance#Trading#Markets#Blockchain#DigitalAssets#YFI#SEC#Regulation#CryptoNews#Innovation#Tech#VC

Venture Village Wall 🦄

@venturevillagewall · Post #4317 · 06.03.2025 г., 01:00

Notable Updates on Crypto Events and Funding White House source confirms Cardano's Charles Hoskinson excluded from the March 8 Crypto Summit. Cardano hasn't engaged with the administration in policy talks. Additionally, DoubleZero Foundation raises $28M at $400M valuation, plans expansion. CANARY files S-1 for AXL ETF, focusing on blockchain interoperability. #Cardano#Crypto#Hoskinson#DoubleZero#Blockchain#Funding#AXLETF#Web3#Investing#Valuation#Solana#XRP#Hedera#Stellar#TON#Sui#Bitcoin#VC#Testnet