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

Пребарај: #peachcat

当前筛选 #peachcat清除筛选
Peach and Goma

@PeachLovesGoma · Post #2535 · 26.04.2024 г., 05:13

Updates 😏 Hello friends, We are currently working on a new animated sticker pack, which is expected to be published at the end of next week 😐. We should also publish an emoji pack in May. New publish date: 2nd week of May Edit: why publishing date is delayed? ❓ We need to release the sticker pack on all social media platforms at the same time, and some platforms like LINE App require a review period before approving and releasing the sticker pack on their own sticker store, which is why the release was delayed. #PeachCat#NewStickers#NewEmojis

🔤🔤🔤 🔤🔤🔤🔤🔤🔤🔤🔤🔤 ❤️ 😘 😘 😂 ❤️ 🥰 😍 😎 😡 👋 😢 😡 🤕 😃 💔 😋 🤨 😫 👉Peach Cat ADD PACK 📝#emoji#PeachCat#Peach_Cat#Cats#Cat#Mochi 👉Канал артов Anime Arts подписаться ❤️Поддержать канал бустом ❤️Заказать стикеры

Peach and Goma

@PeachLovesGoma · Post #2539 · 01.05.2024 г., 03:36

Exciting news! 🎉 Peace Elite aka Game for Peace (Chinese PUBG) and Peach & Goma are teaming up in the world of Peacekeeper Elite! 🎮Tencent Games acquired gaming rights to iconic anime franchise, Peach and Goma! Get ready for epic adventures and adorable Games featuring Peach and Goma. 📱 #PeaceElite#GameForPeace#PUBG#ChinesePUBG#PeachCat#PeachGoma @PeachLovesGoma ❤️