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

Резултати

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

Пребарај: #league

当前筛选 #league清除筛选

🔔The New Year season of the Open League begins! 7th Season of The Open League starts today at 11:00 UTC. Anyone who wants to participate needs to get their #DeFi badges and read the terms of the rewards. The main focus of this season is liquidity💧 The season will last 20 days (from November 27 to December 17). The prize fund is $1.5M. The maximum reward for a participant is $1,000. Points can be earned in two categories: provided liquidity (TVL) and conducted trading turnover (Volume). The user's total points are the sum of the two categories. 💱Volume Points in this category are added for every $20 spent through League member projects. The dollar amount is calculated at the time of the exchange. ✔️GasPump — 5 points ✔️BigPump — 5 points ✔️Blum Mempad — 5 points ✔️TONPump — 5 points ✔️Wagmi — 5 points ✔️swap.coffee — 1 point ✔️Rainbow Swap — 1 point 🔒Liquidity | TVL Points in this category are added for every $20 invested in the liquidity of the sites that participate in the league. The dollar amount is calculated based on the value of the tokens at the end of the season. ✔️DAOLama — 15 points ✔️Aqua protocol — 15 points ✔️TonStable — 15 points ✔️TONCO — 10 points ✔️Coffin — 10 points ✔️JVault — 10 points ✔️Parraton — 10 points ✔️SettleTON — 10 points ✔️TonPools — 10 points ✔️TON Hedge — 10 points ✔️swap.coffee — 10 points for staking If you want to know how to get the most out of the season, join our chat for League tips. Leave your questions in the comments below this post. Get your badge now!🎁 #TON#SBT#AirDrop#League

跑跑資訊站 KartInfo

@KartInfoTW · Post #294 · 09.10.2021 г., 08:16

今晚五點,韓服 2021 跑跑聯賽第二季總決賽開打! 團體賽是文浩俊經營的戰隊「BLADES」對上循環賽一場都沒輸過但準決賽輸給 BLADES 的「Liiv SANDBOX」,個人賽則是有柳昌賢、朴仁秀和李載赫等多位明星選手登場,相信這次決賽肯定會相當精采 🔥 🏁 聯賽資訊/獎勵:https://kinf.cc/aSKLe ▶️ 追蹤 Google 新聞:https://kinf.cc/gn ▶️ 立即加入 Discord:https://kinf.cc/dc #跑跑卡丁車#KartRider#韓服#聯賽#跑跑聯賽#League#冠軍賽#總決賽