@sickipedia · Post #9696 · 23.02.2025 г., 06:01
"Why are you so calm?". "I never argue with stupid people. I just say 'you're right' and move on. "That's ridiculous!". "You're right." #roast@Sickipedia
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
Пребарај: #roast
@sickipedia · Post #9696 · 23.02.2025 г., 06:01
"Why are you so calm?". "I never argue with stupid people. I just say 'you're right' and move on. "That's ridiculous!". "You're right." #roast@Sickipedia
Hashtags
@sickipedia · Post #9619 · 29.01.2025 г., 07:01
My buddy quit his job at BMW. He of course gave no indication that he was leaving. #roast@Sickipedia
Hashtags
@sickipedia · Post #9601 · 23.01.2025 г., 07:01
My wife asked me, “Can we have some peace and quiet while I cook dinner?” So I took out the batteries from the smoke alarm. #roast@Sickipedia
Hashtags
@sickipedia · Post #9558 · 08.01.2025 г., 11:01
I had a big fight with my wife, I yelled at her, "When you finally die, I'm getting you a headstone that says, 'Here Lies My Wife - Cold As Ever'." "Yeah well," she shouted back, "When you die, I'm getting you a headstone that says, 'Here Lies My Husband - Stiff At Last." #roast@Sickipedia
Hashtags
@sickipedia · Post #9550 · 05.01.2025 г., 15:01
My coworker said: “ You should not eat red meat.” I said, “My grandmother lived to be 97.”… She said, “Did she eat red meat?” I said, “No. She minded her own business.” #roast@Sickipedia
Hashtags
@sickipedia · Post #9512 · 24.12.2024 г., 07:01
I named my daughter after my mother-in-law. Raving Psycho will soon be a year old. #roast@Sickipedia
Hashtags
@sickipedia · Post #9506 · 22.12.2024 г., 07:01
My son’s teacher thinks my son has a low IQ judging by his homework. That’s absurd! My son is perfectly normal! I did his homework. #roast@Sickipedia
Hashtags
@sickipedia · Post #9485 · 15.12.2024 г., 06:01
My wife asked me, "is it just me or is the cat getting fat?" "no, it's just you." #roast@Sickipedia
Hashtags
@sickipedia · Post #9162 · 28.08.2024 г., 11:01
I asked my mom If I was an accident. She said, "No, of course not. Your brother was the accident. You were a mistake". #roast @Sickipedia
Hashtags
@sickipedia · Post #9055 · 24.07.2024 г., 11:01
Politicians and diapers have one thing in common: they should both be changed regularly… and for the same reason. #roast @Sickipedia
Hashtags
@sickipedia · Post #9052 · 23.07.2024 г., 11:01
A man who owned a sausage factory was showing his arrogant asshole son around his factory. Try as he might to impress his snobbish son, his son would just sneer and look down his nose at everything. They approached the heart of the factory, where the father thought, "This should impress him!" He showed his son a machine and said, "Son, this is the heart of the factory. With this machine here we can put in a pig, and out come sausages." The son, unimpressed, said, "Yes, but do you have a machine where you can put in a sausage and out comes a pig?" The father, "Yes son, we call it your mother." #roast @Sickipedia
Hashtags
@sickipedia · Post #8871 · 22.05.2024 г., 11:01
Wife: "How would you describe me?" Husband: "ABCDEFGHIJK." Wife: "What does that mean?" Husband: "Adorable, beautiful, cute, delightful, elegant, fashionable, gorgeous, and hot." Wife: "Aw, thank you, but what about IJK?" Husband: "I'm just kidding!" #roast @Sickipedia
Hashtags