@animal_fighting · Post #281 · 29.09.2022 г., 15:04
Crocodile VS Man One more way to deal with a toothy trespasser😀 #crocodile🐊
Hashtags
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
Пребарај: #crocodile
@animal_fighting · Post #281 · 29.09.2022 г., 15:04
Crocodile VS Man One more way to deal with a toothy trespasser😀 #crocodile🐊
Hashtags
@animal_fighting · Post #22 · 03.05.2022 г., 11:03
Crocodile VS Crocodile There hardly is a winner... #crocodile
Hashtags
@SukoFaultyArtLair · Post #4503 · 01.12.2019 г., 20:52
https://www.furaffinity.net/view/31997665/ #female#crocodile
Hashtags
@animal_fighting · Post #288 · 02.10.2022 г., 15:04
Lion VS Crocodile A dangerous opponent #lion🦁#crocodile🐊
Hashtags
@animal_fighting · Post #159 · 16.07.2022 г., 15:04
Crocodile VS Lions Too big and too sharp-toothed even for three lions #lion🦁#crocodile🐊
Hashtags
@animal_fighting · Post #94 · 11.06.2022 г., 07:03
Crocodile VS Lions It's too dangerous even for a lion pride #crocodile#lion
Hashtags
@animal_fighting · Post #29 · 07.05.2022 г., 07:03
Lions VS Crocodile When a prey is too dangerous even if being outnumbered #lion#crocodile
Hashtags
@animal_fighting · Post #333 · 09.11.2022 г., 19:04
Dog VS Crocodile Good reaction can save life... #dog#crocodile
Hashtags
@animal_fighting · Post #187 · 30.07.2022 г., 15:04
Dog VS Crocodile Terror of the jungle 😁 #dog🐕#crocodile🐊
Hashtags
@animal_fighting · Post #52 · 18.05.2022 г., 11:04
Buffalo VS Crocodile Unlucky hunting #buffalo#crocodile
Hashtags
@zigou23 · Post #136 · 28.04.2021 г., 03:27
抹茶旦旦 #鳄鱼#crocodile https://t.me/addstickers/mochadandan https://t.me/addstickers/mochadandan2 https://t.me/addstickers/mochadandan3 https://t.me/addstickers/mochadandan4_32 透明 https://t.me/addstickers/mcdd_tz 动态 https://t.me/addstickers/dxdongtai11_by_fStikBot https://t.me/addstickers/MoChaDanDan_EYu https://t.me/addstickers/mochadandan4
Hashtags
@animal_fighting · Post #268 · 25.09.2022 г., 10:04
Cat VS Crocodile Hunger makes one more courageous😀 #cat🐈#crocodile🐊
Hashtags