@Learn_English_from_Zero_to_Hero · Post #60680 · 31.03.2026 г., 18:01
#Expressions
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
Пребарај: #expressions
@Learn_English_from_Zero_to_Hero · Post #60680 · 31.03.2026 г., 18:01
#Expressions
Hashtags
@Learn_English_from_Zero_to_Hero · Post #60602 · 26.01.2026 г., 16:56
#Expressions 💥Throw sb off 'course : 🔅if sb/sth is thrown off course, they are forced away from the direction they should be travelling in: ▪️ The plane was thrown off course. 2🔅to force sb to change the direction in which their ideas or actions are moving: ▪️ The government was thrown off course by economic problems.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #60131 · 23.08.2025 г., 18:19
#Expressions 💥Fly the coop. ▪️ (idiomatic) Leave or escape. 💥Once she heard the teacher's voice, she flew the coop .
Hashtags
@Learn_English_from_Zero_to_Hero · Post #60129 · 23.08.2025 г., 18:14
#Expressions 💥Doom and gloom (uncountable) ▪️Something considered indicative of feelings of pessimism and despair. ▪️Antonyms: rainbows and unicorns, sunshine and rainbows. ⚡️The economic forecast contained the usual doom and gloom. ⚡️His sister was all doom and gloom after she lost the part.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #60128 · 23.08.2025 г., 18:12
#Expressions 💥No great shakes (uncountable) ▪️(idiomatic) Something unexceptional, not noteworthy or special. ▪️Synonyms: nothing to write home about ⚡️You're welcome to stay here, but this hut ain't no great shakes for such as you.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59967 · 30.07.2025 г., 19:01
#Expressions 💥raring to do something (BrE) ● very eager to do something ⚜The children were raring to get outdoors.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59966 · 30.07.2025 г., 19:01
#Expressions 💥on the brink ●(idiomatic) Very nearly; imminent; close. ⚜The old building seemed to be on the brink of collapse.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59965 · 30.07.2025 г., 19:01
#Expressions 🔘on the level ▪️(idiomatic) Honest(ly), sincere(ly), straightforward(ly), fair(ly). 🔸He looks like a used car salesman, but he's really on thelevel, so you can trust him.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59936 · 24.07.2025 г., 19:00
#Expressions 💥Finer things ●That which is considered of a high quality, expensive or tasteful. •Example: ⚡️I'm not materialistic, though I do enjoy the finer things in life.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59935 · 24.07.2025 г., 19:00
#Expressions 💥Lose sleep over something •to worry about something •Example: ⚡️I know she's angry with me, but I'm not losing any sleep over it.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59934 · 24.07.2025 г., 19:00
#Expressions 💥Take the plunge •to do something important or difficult, especially after thinking about it for a long time. ●Example: ⚡️We're finally going to take the plunge and buy a house.
Hashtags
@Learn_English_from_Zero_to_Hero · Post #59909 · 23.07.2025 г., 06:16
#Expressions 💥Lend itself to sth FORMAL •to be suitable for a particular purpose •Example: ⚡️The novel's complex, imaginative style does not lend itself to translation.
Hashtags