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

Пребарај: #suggestions

当前筛选 #suggestions清除筛选
Pensive|

@PensivePost · Post #5769 · 27.05.2022 г., 04:17

Chapter 1:The cuckoo's nest The irksome sound coming from someone's radio , "it must be morning " i muttered , tho i dont usually wake up this early on a holiday like this , so i tried to cover myself in the warmth of blanket but not enough to insulate that annoying noise and so i gave up on my dream. The sun was dim today quite unusual day for a summer . A strong pingent smell caught my glemse , after using my brain and nose i was able to find the cordinates of its origin. "Its coming from my balcony "i shouted , I jumped out of my blanket and opened the balcony , There was a dead cuckoo lying on the floor , might have fallen from its nest . I usually come to see this cuckoo been feed by a small Canary , that was a quite appealing view to watch or rather entertaining. The decaying body of cuckoo was alluring alot of bugs and ants, "Someone will live on someone's death" i said on a quavering voice , My neighbour was also in his balcony watching that cuckoo's , his balcony was just 1 feet away from mine . Unlike me his balcony was been decorated with lot of flowers , pot were hanging on the side of his wall. A green fluffy carpet all over his wall, giving more athestic look to his balcony , on the other hand my balcony have alot of poops of the birds which i never bothered to clean , a rusty chair which got its rust by weting in the rain , some clothes hanging here and there , being just 1 feet away and paying the same rent there was a lot of difference in our balconies , or rather alot of difference in our personality . He usually come to water his plants tho we never talked before. After spending few more minutes in balcony gloring the blueness of sky , I went back to my room , my stomach was starving by the time , I quickly went to check on my fridge for something to eat , even my bad luck is unlucky ,it just contains some rotten yogurts , broken beer bottles , a pouch of sous which is expired , a frozen fish . I went to my kitchen and found that i was out of instant noodles too. #review #novel #suggestions

GitHub Trends

@githubtrending · Post #15383 · 02.01.2026 г., 11:30

#go#customer#feature_request#feedback#ideas#suggestions Fider is a simple tool for collecting customer feedback, feature requests, and votes to prioritize what users want most. Use Fider Cloud for quick managed setup or self-host it free on your servers. Customize it, invite users to suggest ideas, vote, and discuss, then update statuses like "planned" or "done" to keep them informed. This saves time guessing needs, boosts customer loyalty through engagement, and helps build better products efficiently. https://github.com/getfider/fider