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

Резултати

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

Пребарај: #stake

当前筛选 #stake清除筛选
stake_PG

@stake_PG · Post #74 · 23.06.2024 г., 16:39

2023年1月,阿尔法·罗密欧F1车队宣布,Stake将成为他们的冠军赞助商,为期多年,车队更名为“阿尔法·罗密欧F1车队股份”。 #Stake 是一家澳大利亚-库拉索大陆的在线赌场。它由Medium Rare NV运营,拥有在线赌场许可证。这是一家全球性公司,在塞尔维亚、澳大利亚等设有办事处,在全球设有员工,提款秒到协议出款无需审核! #Stake国际站: stake.com/?c=AGnyo6qr 不限ip 充提秒到

1 BILLION 😎DOGS AT STAKE✅ 🤑DOGS is a memecoin created by the Telegram community and inspired by the iconic character Spotty, the mascot of VK. Today you will be able to take part in the promotion by completing three tasks: ✔️Join the promotion ✔️Trade DOGS with an amount of 100 USDT or more ✔️Invite your friends! 🎈 Prize pool for trading is 900,000,000 DOGS 🎈 Prize pool for invitations is 100,000,000 DOGS Deadline: September 23, 23:59 (UTC) #OKX#trade#stake#TON#DOGS

🤝 Storm Trade x EVAA x Tonstakers: a Power Strategy for Liquidity Providers How to put your $TON to work more effectively in DeFi? Three top-tier TON protocols — #StormTrade, #EVAA, and #Tonstakers — have joined forces to introduce a layered liquidity strategy that helps you boost rewards across multiple platforms simultaneously. The core idea: use the same asset across several protocols and earn rewards in each one: 🔵 EVAA 🔵 Storm Trade 🔵 Tonstakers ⚡️Aggressive Strategy: 1️⃣ Stake your $TON with @tonstakers_bot to receive $tsTON (~4% APR). 2️⃣ Supply $tsTON in EVAA — earn 2 XP for every $1 supplied. 3️⃣ Borrow $TON on EVAA — earn 5 XP for every $1 borrowed. 4️⃣ Trade the borrowed $TON on Storm Trade — earn ✖️ twice more RP per $1 in volume. ✅Moderate Strategy: Prefer lower risk? Borrowed $TON from EVAA can be deposited into the Storm Trade TON Vault to earn up to 20% APR. You’ll still receive ✖️ RP rewards. 🗓️Campaign Dates: April 15–25, until 15:00 CET 🥇😇🐸 Rewards will be distributed after the campaign ends. #Degen#DeFi#Stake#Vault#Supply

X

@PROJECT · Post #32 · 25.12.2024 г., 21:58

🚀 Grab #CDB#Tokens NOW Before They Hit $0.015 in Jan 2025! ⏳ Only a Few Days Left! #Stake, #hold, & prepare for #BIG profits with the $0.020 listing #coming in Feb 2025! 💥 Don’t Miss Out—Act #Fast! 🔗https://cloudatabox.com/register?ref_code=6515554&pos=right #CDBToken#CryptoProfits#StakeAndEarn#Cloudatabox