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

Резултати

Пронајдени 3 слични објави

Пребарај: #chaveztheradical

当前筛选 #chaveztheradical清除筛选
Venezuelanalysis

@venanalysis · Post #2014 · 26.06.2025 г., 20:03

🎥 VIDEO | Chávez the Radical XXIX: ‘You Are Not Small Businesspeople’ One of the goals of capitalist ideology is to hide or downplay class struggle. Instead, it seeks to foster individualism over collective processes. Former Venezuelan President Hugo Chávez looked to dispel these myths in a 2012 speech, reminding those who take part in the informal economy that they are not small businesspeople but belong to the working class. 👉 Watch the full video here: https://shorturl.at/D1IgI #HugoChavez#ChaveztheRadical

Venezuelanalysis

@venanalysis · Post #2032 · 17.07.2025 г., 21:24

🎥 VIDEO | Chávez the Radical XXXI: ‘It’s Impossible for Capitalism to Have a Human Face’ The episode features a 2006 speech in which Hugo Chávez argues that capitalism cannot be humanized and must be overcome. It also traces his political evolution, from initially advocating a 'Third Way' between capitalism and socialism to affirming socialism as the necessary path for the Bolivarian Revolution. 👉 Watch the full video here: https://venezuelanalysis.com/video/chavez-the-radical-xxxi-its-impossible-for-capitalism-to-have-a-human-face/ #ChavezTheRadical#HugoChavez#TatuyTV

Venezuelanalysis

@venanalysis · Post #2341 · 20.04.2026 г., 19:48

🎥 VIDEO | Chávez the Radical XXXII: ‘The Bonus-over-Wage Policy Pulverized Incomes’ The episode features a 2006 speech in which Hugo Chávez criticizes policies that replaced wages with bonuses, arguing they increased labor precarity and favored business interests. It also examines how, in recent years under US economic sanctions, Venezuela has expanded non-wage bonuses, generating debate within Chavismo and criticism from trade unions over their impact on incomes. 👉 Watch the full video here: https://venezuelanalysis.com/video/chavez-the-radical-xxxii-the-bonus-over-wage-policy-pulverized-incomes/ #Wages#ChavezTheRadical#HugoChavez#TatuyTV