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

Пребарај: #ocular

当前筛选 #ocular清除筛选

❤️Vanilla Finance Closes Pre-Seed Investment Round ✔️ Singapore, November 26, 2024 – Vanilla Finance, the leading exchange by trading volume on #Telegram, has announced the successful closure of its Pre-Seed investment round. Spearheaded by industry giants like Paper Ventures, UOB Ventures, and ABCDE Labs, the round also attracted notable participants such as #HTX Ventures, #Ocular, #Openspace, #Y2 Ventures, and angel investors from #STEPN, #Scroll, #XAI, and more. 🔫A Game-Changer in the Digital Asset Space Since its launch, #VanillaFinance has made waves, amassing over $8 billion in USDT trading volume within just 60 days. This meteoric rise is further validated by winning the prestigious #Binance MVB Season 8, a recognition of the platform’s cutting-edge solutions and market leadership. 👏Visionary Growth and User-Centric Innovation With fresh funding and institutional backing, Vanilla Finance is on a mission to redefine crypto trading by: • Simplifying User Experience: Introducing intuitive, secure features tailored for both novices and experts. • Expanding Offerings: Launching a spot market, with a focus on meme trading pairs, and rolling out features like a meme creator platform, staking products, and futures trading. • Regional Focus: Targeting Southeast Asia and APAC with localized services, multilingual support, and integration with regional payment systems. 💰Institutional Confidence in a Bright Future The involvement of strategic investors highlights Vanilla Finance’s potential. A UOB Ventures spokesperson praised the platform’s innovative approach, while Danish Chaudhry of Paper Ventures noted, “Vanilla Finance’s expansion aligns perfectly with the Southeast Asia and APAC markets’ untapped opportunities in digital finance.” 📖Building a Next-Generation Ecosystem Beyond trading, Vanilla Finance is creating an ecosystem that prioritizes community engagement and innovation. With its unique approach to meme trading and user-focused features, the platform is poised to set a new benchmark in digital asset trading. ✈️The Future Starts Here: Vanilla Finance is committed to serving the next 100 million users, shaping a more inclusive, engaging, and forward-thinking crypto landscape. ❤️ Join Vanilla mini-app now and get as much $CONE as you can before the airdrop!