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

Резултати

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

Пребарај: #skillgaming

当前筛选 #skillgaming清除筛选
TONlines – News

@tonlines · Post #6981 · 30.04.2025 г., 11:55

⚡️TapSwap Community: Major News Incoming Tomorrow! #TapSwapBeta#SkillGaming#Web3Games TapSwap Community announces a major update about their private beta launching tomorrow, featuring three exclusive skill-based games in Telegram. Limited spots are available, and interested participants should prepare to apply using a Google form link with their Telegram handle. Source: link @tonlines

TONlines – News

@tonlines · Post #6772 · 15.04.2025 г., 09:28

TapSwap Community: Elevate Your Gaming Skills with Precision #SkillGaming#TapToWin#ClassicWithCrypto The TapSwap Community emphasizes skill and precision in classic games like Tetris, Solitaire, and Bubble Shooter. Players are encouraged to hone their focus and ability to outplay and earn, adding purpose to their gaming experience. Source: link @tonlines

Nigeria Football Hub

@football_nigeria · Post #1098 · 19.05.2025 г., 14:01

🎮TapSwap officially launched the beta! The project has made an important step forward — now skill games are available for the first testers directly in Telegram. Convenient format, fast loading and no unnecessary actions. What's included in the beta: • 🎯 Three games where the outcome depends on your skills • 💰 Integration with $TAPS • 📲 Access via Telegram mini-app ⚠️ At the current stage, only selected users have access to the beta. If you are among them, you can already try out the platform before the official release. 🗓The public launch is scheduled for early June. #TapSwap#БетаЗапуск#SkillGaming#Web3UA Bot link:tapswap_bot📱 Nigeria Football Hub

INSIDER USA | News

@insider_usa_news · Post #3352 · 19.05.2025 г., 13:04

🎮TapSwap officially launched the beta! The project has made an important step forward — now skill games are available for the first testers directly in Telegram. Convenient format, fast loading and no unnecessary actions. What's included in the beta: • 🎯 Three games where the outcome depends on your skills • 💰 Integration with $TAPS • 📲 Access via Telegram mini-app ⚠️ At the current stage, only selected users have access to the beta. If you are among them, you can already try out the platform before the official release. 🗓The public launch is scheduled for early June. #TapSwap#БетаЗапуск#SkillGaming#Web3UA Bot link:tapswap_bot📱 INSIDER USA 👉🏻 Subscribe