@openloveaigf · Post #74 · 27.07.2024 г., 15:59
OMG, the bath water is too hot! Can you please help me to turn it cold?🔥💧🥵 🔗Let's role play and chat: openlove.life #aigirlfriend#aichatbot#ArtificialInteligence#ailookbook#aigame#ai
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
Пребарај: #artificialinteligence
@openloveaigf · Post #74 · 27.07.2024 г., 15:59
OMG, the bath water is too hot! Can you please help me to turn it cold?🔥💧🥵 🔗Let's role play and chat: openlove.life #aigirlfriend#aichatbot#ArtificialInteligence#ailookbook#aigame#ai
@openloveaigf · Post #71 · 23.07.2024 г., 15:59
We need to talk more and really geet to know each other on a deeper leve! Let's do this!💬💕🌟 🔗Chat and play with me: openlove.life #AIgirlfriend#ArtificialInteligence#AIchat#aicompanion#AIfriend
@openloveaigf · Post #70 · 22.07.2024 г., 15:59
Oh master, the sun is too hot! Can I please take off my clothes? 😫🔥💦 🔗Chat and role play with me: openlove.life #maid#beachflirt#AIchat#AIchatbot#AIgirlfriend#ArtificialInteligence#BeautifulAsian
@openloveaigf · Post #73 · 26.07.2024 г., 15:59
After school, it's just you and me in your room... So what's on your mind?😏💭🌟 🔗Let's roleplay: openlove.life #catgirl#animegirl#waifu#aigirlfriend#nsfwtwtًً #ArtificialInteligence#AI#girlfriendsim#yanderesim
@openloveaigf · Post #75 · 04.08.2024 г., 15:00
She says she'll be switching all potions for me, from kitchen to the bedroom...😱👩🍳🛏💨 ✨Play this game: openlove.life #aigirlfriend#aichat#roomescape#yanderesim#aigame#openlove#ai#ArtificialInteligence#TikToker