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

Пребарај: #craigwright

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

@venturevillagewall · Post #3605 · 20.12.2024 г., 18:00

K33 Predicts Bull Run Peak Date 📈 K33 analysts forecast the peak date of the bull run. ⚖️ Craig Wright receives a conditional sentence for contempt of court. 💵 VC investors are retreating from crypto as the market shifts. 📊 Bitcoin's failure at $100K triggered over $1 billion in liquidations. 🐋 El Salvador expands Bitcoin purchases despite IMF deal. 💬 Tornado Cash co-founder demands dismissal of charges. 👾 Ilya Lichtenstein claims sole responsibility for Bitfinex hack. 💰 Cryptopia clients received $225 million in assets from liquidators. ✅ SEC approves first hybrid ETFs based on Bitcoin and Ethereum. 👁 German regulator orders World to delete user data. 👀 Investors file a lawsuit against the HAWK token team. ⚽️ American football player to receive part of salary in Bitcoin. 🚀 Cathie Wood confirms Bitcoin price prediction above $1 million. #K33#CraigWright#Crypto#Bitcoin#Liquidations#ElSalvador#TornadoCash#Bitfinex#Cryptopia#SEC#ETFs#Germany#HAWK#Football#CathieWood#Investors#Funding#VentureCapital#Market#Investments

Venture Village Wall 🦄

@venturevillagewall · Post #3602 · 20.12.2024 г., 17:03

Crypto Highlights: Recent Developments 📈 K33 analysts have predicted the peak date of the bull run. ⚖️ Craig Wright received a conditional sentence for contempt of court. 💵 VC investors are leaving crypto, while crypto distances itself from VC investors. 📊 A Bitcoin crash at $100,000 led to over $1 billion in liquidations. 🐋 El Salvador expanded its Bitcoin purchases despite an IMF deal. 💬 Tornado Cash co-founder demands charges be dropped. 👾 Ilya Lichtenstein claims sole responsibility for the Bitfinex hack. 💰 Cryptopia clients received $225 million in assets from liquidators. ✅ SEC approved the first hybrid ETFs based on Bitcoin and Ethereum. 👁 German regulator ordered World to delete user data. 👀 Investors sued the team behind the HAWK token. ⚽️ An American football player will receive part of his salary in Bitcoin. 🚀 Cathy Wood confirmed her Bitcoin price prediction exceeds $1 million. 🤑 Colin Wu shared the success story of a 24-year-old crypto trader. #K33#CraigWright#VC#Bitcoin#Liquidation#ElSalvador#TornadoCash#Bitfinex#Cryptopia#SEC#ETFs#Germany#HAWK#Football#CathyWood#CryptoTrader#CryptoNews#Investments#MarketTrends#CryptoRegulation#Blockchain