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

Пребарај: #environmentalengineering

当前筛选 #environmentalengineering清除筛选
Green University CA | Official

@centralasian_greenuniversity · Post #212 · 15.10.2025 г., 12:53

🇪🇺Green University Hosts the 3rd GREENDT Project Meeting! 🗣From October 14 to 17, 2025, Green University hosts the third project meeting and training seminar within the framework of the Erasmus+ GREENDT project — “Implementing Environmental Engineering Master Degrees through Sustainable Transition and Societal Change.” The GREENDT project, funded by the European Union, aims to develop and implement an innovative Master’s program in Environmental Engineering — empowering universities to train future experts who will lead sustainable transformation and support climate action. 💬The event brought together participants from European and Uzbek universities and research institutions. During the sessions, partners discussed project achievements, future plans, and took part in training activities designed to strengthen teaching and institutional capacities in the field of environmental education. #GreenUniversity#GREENDT#ErasmusPlus#Sustainability#EnvironmentalEngineering#HigherEducation#ClimateAction ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #275 · 30.10.2025 г., 11:38

🇮🇹Italy Delegation Visits Green University 📌On October 28, 2025, Green University welcomed a high-level Italian delegation led by H.E. Federico Failla, Ambassador Extraordinary and Plenipotentiary of Italy to Uzbekistan. ✔️During the visit, Acting Rector Sh. Nurulloyev presented the university’s educational, research, and international initiatives and guided the guests through Green University’s campus, research institutes, and climate residence. The Italian side proposed several key initiatives, including: 🟡Joint master’s programs in ecology and environmental engineering; 🟡Student and faculty exchange programs; 🟡Regional events on water management; 🟡Joint research projects on environmental protection and waste recycling; 🟡Establishment of the Italy–Central Asia Environmental Cooperation Center at Green University; 🟡Support for innovative green economy startups. #GreenUniversity#Italy#Cooperation#Sustainability#GreenFuture#EnvironmentalEngineering#Education#ClimateAction ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube