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

Пребарај: #upskilling

当前筛选 #upskilling清除筛选
StartupBase

@startupbaseuz · Post #5119 · 01.12.2024 г., 08:52

Together with Coursera, we are working on massive upskilling of our youth. In addition to comprehensive reforms at all levels of education, Uzbekistan will be an excellent source of affordable talent for ITES companies for the years to come. We are also fully covering all IT training and certification costs for those who have B2 level foreign languages as well as subsidizing IT training companies up to $2000 for every successful graduate employed at ITES company or up to $3000if s/he is disabled. We fully understand that for ITES companies to expand their delivery centers in Uzbekistan good demographics is not enough and therefore we invite other training companies also to use these opportunities to grow their business with us and help our youth to become more competitive in a global remote work landscape. The main goal is to equip our growing young population with the most important skills in demand by ITES exporting companies for them to succeed in their future careers. So if you are planning for the longer-term flow of affordable talent coupled with tax breaks up to 2040 look for Uzbekistan and register your ITES exporting company with IT Park through https://outsource.gov.uz #Uzbekistan#IT_Hub#Talents#Upskilling#Tax_breaks_2040

Venture Village Wall 🦄

@venturevillagewall · Post #3543 · 20.12.2024 г., 09:31

MRI Simulator Secures $3.5M Corsmed has successfully raised $3.50M to enhance its MRI simulator, which provides an affordable, realistic training solution for students and technicians. This technology allows hands-on experience for just 1% of the cost of traditional MRI scanners, expanding training opportunities significantly. #Corsmed#MRI#Simulator#Healthcare#Training#EdTech#Innovation#Financing#MedicalTraining#TechFunding#Startup#Students#Technicians#AffordableHealthcare#HandsOnTraining#SkillsDevelopment#Technology#Upskilling#AffordableTech#MedicalEducation