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

Пребарај: #defitakeover

当前筛选 #defitakeover清除筛选
TON Crypto News

@toncoin_rap · Post #159 · 21.09.2024 г., 06:39

🎧⤴ 🤑TON Ecosystem on Fire! Major Updates from Fintopio, TBook, and XDAO You Can’t Miss This week, the TON blockchain ecosystemrolled out exciting updates across three projects: Fintopio, TBook, and XDAO. Fintopio, one of the fastest-growing DeFi wallets on Telegram, now has 6 million active monthly users, offering fee-free transfers and NFT storage. TBook introduces free TON WISE Credit Scores, encouraging users to showcase their onchain and offchain activities for potential rewards. Lastly, XDAO is pioneering the first DAO ecosystem on TON, integrating Telegram mini-apps and introducing community-driven farming games to attract new users. TON’s rapid growth continues, with a thriving Web3 community ready to reshape digital finance. Chorus: We on TON, leveling up the game, Fintopio's flexin’, ain’t nothin' the same. TBook’s credit stack, XDAO’s on the rise, Decentralized future, right before your eyes. Verse 1: From Telegram straight to the blockchain scene, Fintopio’s the wallet that’s keepin' it clean. Millions logged in, sending cash for free, DeFi on your phone, simple as can be. $HOLD points stackin’, rewards gettin’ high, Move fast, earn big, touch the sky. Security tight, but the game’s still smooth, Digital assets now got nothin' to lose. Chorus: We on TON, leveling up the game, Fintopio's flexin’, ain’t nothin' the same. TBook’s credit stack, XDAO’s on the rise, Decentralized future, right before your eyes. Verse 2: TBook’s in the mix, building up your score, Onchain data, you got rewards in store. Credit's climbing high, opportunity knocks, Show what you’ve done, you control the stocks. Airdrops comin’ in, WISE Credit the key, Exclusive deals, it’s the place to be. You a star on the rise, now the world’s in view, Link up your past, and the rewards come through. Chorus: We on TON, leveling up the game, Fintopio's flexin’, ain’t nothin' the same. TBook’s credit stack, XDAO’s on the rise, Decentralized future, right before your eyes. Verse 3: XDAO’s movin’ fast, DAOs on the map, Farming those coins while you sit back and tap. Mini apps in play, communities grow, TONxDAO tech, let the future flow. Buildin' syndicates, big moves you choose, DAO-based biz, ain’t no time to snooze. Empowerin’ users, decentralize it all, New age of finance, watch the empires fall. Chorus: We on TON, leveling up the game, Fintopio's flexin’, ain’t nothin' the same. TBook’s credit stack, XDAO’s on the rise, Decentralized future, right before your eyes. Bridge: No more middlemen, we takin' control, In the TON ecosystem, we’re playin' the role. From wallets to scores, and DAOs takin' flight, It’s a Web3 revolution, we shine in the night. #TONBlockchain#DeFiTakeover#Web3Revolution #TONCryptoNewsRapStyle 🎧@toncoin_rap