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

Резултати

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

Пребарај: #cascadingwins

当前筛选 #cascadingwins清除筛选
TRUE LABS

@truegames · Post #15 · 11.06.2024 г., 20:00

FRUIT CIRCUS PARTY brings fruit carnage to a whole new level! Step right up, there's a new circus in town! 🎪 Cascading wins unlock fresh combos & crank up the multipliers. Madness begins June 27th! 🗓️ ➡️ DEMO: https://truelab.games/games/fruit-circus-party #FruitCircusParty#CascadingWins#MultiplierChaos#TrueLab#TrueGames#TrueSlots

TRUE LABS

@truegames · Post #17 · 18.06.2024 г., 10:01

Tired of boring fruit games? We’ve got you covered. Our latest game, FRUIT CIRCUS PARTY, features multiplicative multipliers with no limits! That’s right, endless chaos and infinite potential! 🎢 Charge the multipliers by landing wins and triggering cascades. The more you win, the crazier it gets, and we mean CRAZIER! You can even use the Buy Bonus to head straight into the bonus round, where multipliers don't reset and only head upwards. Because who needs stability, right? 🎪💥 We’re just 10 days away from launching this fruity frenzy. Mark your calendars for June 27th! Can't wait? Hit up the demo right here! ➡️https://bit.ly/demo-fcp #FruitCircusParty#MultiplicativeMultipliers#CascadingWins#BuyBonus#TrueLab#TrueGames#TrueSlots