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

Пребарај: #procrypto

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

@venturevillagewall · Post #3863 · 13.01.2025 г., 10:00

Trump's Crypto Council to Include CEOs The Trump administration is set to form a crypto advisory council, appointing around 24 CEOs and industry leaders. The council aims to advise on digital asset policies, collaborate with Congress on crypto legislation, and work with agencies like the SEC and CFTC to foster a pro-crypto environment. A possible outcome could be the establishment of a strategic Bitcoin reserve for the U.S. Read more: Wu Blockchain News #Crypto#Trump#SEC#CFTC#Bitcoin#Legislation#Finance#DigitalAssets#AdvisoryCouncil#USPolicy#ProCrypto#Innovation#MarketTrends#Leadership#TechNews#Blockchain#Government#Investments#VC#USEconomy

Venture Village Wall 🦄

@venturevillagewall · Post #4007 · 28.01.2025 г., 10:00

Metaplanet Plans $745M Bitcoin Purchase Tokyo-listed Metaplanet aims to raise ¥116 billion (approx. $745M) through 21 million share subscriptions at 0% discount for Bitcoin acquisitions. This represents one of the largest financing plans for Bitcoin by any Asian publicly traded company. Detailed info available here: link. Meanwhile, U.S. Bitcoin and Ethereum ETFs received $1.9B in inflows during Trump's first week, bringing total digital asset inflows for 2025 to $4.8B. U.S. Senate also confirmed pro-crypto Scott Bessent as Treasury Secretary, expected to influence crypto regulations amid heightened interest. #Bitcoin#ETF#Crypto#Investment#Metaplanet#Asia#Treasury#DigitalAssets#BTC#ETH#Finance#NASDAQ#WallStreet#MarketTrends#Inflows#Securities#Cryptocurrency#USeconomy#Regulations#Trump#ProCrypto

Venture Village Wall 🦄

@venturevillagewall · Post #3761 · 31.12.2024 г., 16:00

Bitcoin Surpasses $100K: Retail Investors Return 💰 Bitcoin recently soared above $100,000, briefly reaching $104K, before settling below $91K. This surge is linked to key pro-crypto appointments in the Trump administration, including Scott Bessent for Treasury and Paul Atkins as SEC chair. 🚀 Retail interest is on the rise, with older cryptos, termed 'dino coins', gaining attention. XRP reclaimed its place as the fourth largest cryptocurrency as investors return to the market. Millennial parents are now considering Bitcoin as a safer option, encouraged by large firms like Blackrock. 📈 Ethereum is benefitting too, with ETF inflows exceeding Bitcoin on multiple occasions and blue-chip NFTs based on ETH seeing increased floor prices. 🔍 As the crypto market evolves, understanding the current market cycle can aid investment strategies. 📅 Major firms dominate crypto ETF races, with BlackRock leading in both Bitcoin and Ethereum spaces. For more details, check the full article here: Leviathan News. #Bitcoin#Crypto#VC#XRP#Ethereum#NFT#Blackrock#ETF#Investment#Retail#DePIN#ProCrypto#MarketTrends#DigitalAssets#Milestone#MarketCycle#Altcoins#Trump#CryptoCommunity#DinoCoins#PaulAtkins