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

Пребарај: #futuremindssummit

当前筛选 #futuremindssummit清除筛选
Opportunities with Zula

@opportunities_zula · Post #1859 · 16.04.2026 г., 18:48

Yes, you heard it right! The Future Minds Summit covers your airfare, meals, accommodation, and even your visa costs. Eligibility: Open to Worldwide Participants 📍 Bangkok, Thailand 🇹🇭 🗓 Event Dates: 16-19 July 2026 ⏳ Deadline: 16 June 2026 👉 Apply here: https://thegyn.org/fms-thailand/ (link in bio) #FutureMindsSummit #Thailand #CallForDelegates#YouthLeadership#FundedOpportunity FMST

Opportunities with Zula

@opportunities_zula · Post #1845 · 15.04.2026 г., 10:44

📣 Call For Worldwide Applications! The Future Minds Summit Thailand 🇹🇭 2026 invites motivated youth from across the world to take part in a global leadership and Intellectual dialogue on Sustainable Development Goals in Bangkok, Thailand 🎓 Theme: Exploring Sustainability through Innovative Minds 🌍 Open to Worldwide Participants Scholarship Covers: ✈️ Airfare 🗄️ Visa Fees (if any) 🏨 Accommodation 🍽 Meals & Tea Breaks 📄 Visa support & Certification 🎙️ Speaking Opportunity at the Forum 🤝 All Social Activities & Cultural Fest 🗓 Event Dates: 16-19 July 2026 ⏳ Deadline: 16 June 2026 👉 Apply here: https://thegyn.org/fms-thailand/ #FutureMindsSummit #Thailand #CallForDelegates#YouthLeadership#FundedOpportunity

Opportunities with Zula

@opportunities_zula · Post #1857 · 16.04.2026 г., 15:42

Bangkok is Calling Future Leaders! Visit: https://tinyurl.com/fms-thailand2026 Applications are now open for the GYN FutureMinds Summit 2026 in vibrant Bangkok, Thailand Whether you're a student, graduate, or professional (ages 16–45), this is your chance to connect, learn, and lead on a global stage. No specific background required — just passion and vision! What’s Covered? Airfare Accommodation Meals & Tea Breaks Visa Support & Fees (if applicable) Speaking Opportunity Cultural Fest & Social Activities Certification Join a diverse network of changemakers, gain international exposure, and make your voice heard where it matters. Tag someone who shouldn’t miss this opportunity! #FutureMindsSummit#FullyFunded#YouthLeaders#GlobalOpportunities#Bangkok2026#Changemakers#ApplyNow