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

Пребарај: #reputation

当前筛选 #reputation清除筛选
Nomis | Onchain Reputation Protocol

@nomis_protocol · Post #524 · 06.11.2024 г., 13:06

​​ALL NOMIS SUPPORTERS IN #GG22 — THANK YOU FOR YOUR LOVE 💜 🚨 Only 15 hours left in Gitcoin #Grant, and we're close to the top because of your support: If you're still with us, we welcome your tweets, donations, and any support you can offer for #GG22 We build for you, post for you, and exist to make your #reputation matter! Thank you for making us matter 💜

Nomis | Onchain Reputation Protocol

@nomis_protocol · Post #495 · 23.10.2024 г., 18:42

HOW TO #CRYPTO: Safe, Smooth, and Smart? We're here to teach you! How exactly? Let's break it down, fam 🧵👇 1️⃣ By letting you leverage your #onchain reputation without doxxing and sharing your personal data. You're fine w/ just your wallet, anon. 2️⃣ By being clear in public: answering your questions, assisting you, supporting you 👥 That’s why we vibe with you on Twitter Spaces! 💜 BTW, check the latest one to get our full point on safety tools and onchain #reputation in crypto 👇 https://twitter.com/i/spaces/1djGXrZDqmNxZ 3️⃣ Educating users on onchain reputation and privacy! Making sure your decentralized identity stays safe while keepin’ it simple We don’t gatekeep and give YOU full transparency into our algorithms so you can actually see how your onchain rep works 🔎https://nomis.cc/blog/what-nomis-scores-knows-about-you👈 4️⃣And simply by letting the TON #Blockchain do their job 🤠 Education is key. We believe our allies could move this narrative towards mass adoption. And Nomis (that's us!) will be alongside 🥰 Start your onchain journey! Check your reputation -> nomis.cc/ton👈 💠Nomis tApp | X | Discord | YouTube | Check Scores⚖️

MPA GLOBAL

@mpa_creative · Post #317 · 11.12.2022 г., 00:00

MPA creative media agency📽Production "Ayol va biznes - o'sishga qodirmiz!" forum kunida namoyish qilingan qisqa metrajli film. Xar hil yo’nalishdagi tadbirlar, loyihalar va uchrashuvlarni nufuzli tarzda o’tkazishiga siz ham guvoh bo’lishingiz mumkin. Biz hamisha yangi hamkorlikka tayyormiz🤝 #media#pr#reputation#production #creative#content#forum