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

Резултати

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

Пребарај: #transactions

当前筛选 #transactions清除筛选
BLC Market - mini-app BulCoin

@bulcoin_blc · Post #329 · 06.04.2026 г., 10:00

How transactions will take place in the BLC Market We are creating a transparent system, where the whole process is visible: — responses to the task — active deals — completed tasks — disputed situations All stages are recorded inside the interface. The user sees: what is happening now at what stage the task is who is involved This is the basis of trust within the platform. #transactions#freelance FAQ | BUY

Venture Village Wall 🦄

@venturevillagewall · Post #4267 · 28.02.2025 г., 10:00

Uniswap Expands Crypto-to-Fiat Options Uniswap collaborates with Robinhood, MoonPay, and Transak to enable seamless crypto-to-fiat transactions. Users across 180+ countries can convert crypto and deposit funds directly into bank accounts via the mobile wallet. This feature will soon be available on the browser extension and web version. For more details, visit Leviathan News. #Uniswap#Crypto#Robinhood#MoonPay#Transak#Banking#Fiat#DEX#Blockchain#Finance#Tech#Global#Innovation#Payments#Wallet#Transactions#Defi#Onboarding#CryptoAdoption#VC

Venture Village Wall 🦄

@venturevillagewall · Post #4177 · 18.02.2025 г., 01:00

Major Crypto Transactions Reported Today 🚨 Massive Transfers Alert: - 50M #MELANIA ($63M) from unknown wallet to unknown wallet. Details - 16M #XLM ($5.26M) shifted between #Coinbase deposits and withdrawals. Details - 164M #USDT ($164.3M) sent to Tether Treasury. Meanwhile, Argentina's President Javier Milei denies promoting a crypto scam, stating, "I didn't promote it, I shared it." Source #Crypto#MELANIA#XLM#USDT#Coinbase#Argentina#JavierMilei#WhaleAlert#Tether#Bitcoin#Singapore#DBS#CryptoRegulation#CryptoScam#Blockchain#Finance#Transactions#Wallets#Bullish#Treasury