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

Резултати

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

Пребарај: #legend

当前筛选 #legend清除筛选

Один из ключевых летних привозов для поклонников электронной музыки состоится 19 июля. Алматы впервые посетит именитый японец ¥ØU$UK€ ¥UK1MAT$U, который является яркой фигурой андеграунда Японии. Его выступление в Алматы станет последним в рамках его летнего тура. BONUS that we deserve: https://www.youtube.com/live/WvyvwlowHWM?si=21Q6cN70A6szW6W6&t=1357 -- -- -- -- @AlmaDvizh#legend#epic#dj

Interesting Planet 🌍

@interesting_planet_facts · Post #1099 · 04.12.2025 г., 18:11

🌎 The Aztec legend of Quetzalcoatl describes a feathered serpent god who brought knowledge and culture to people. Spanish chronicles report Aztecs believed Quetzalcoatl created humans by mixing his blood with ground bones from the underworld. ✨ #aztecs⚡#mythology⚡#legend 👉subscribe Interesting Planet 👉more Channels ​

Alexa Mods

@itsmealexaliza · Post #1056 · 10.10.2024 г., 08:11

India has lost a legend today. Ratan Tata, an extraordinary industrialist, visionary, and humanitarian, has left us. His contributions to the business world and society are unparalleled. He was not just a leader but an inspiration, embodying humility, integrity, and compassion. The legacy he built through the Tata Group and his philanthropic efforts will continue to inspire generations to come. Rest in peace, Ratan Tata Sir. You will forever be in our hearts. 🙏 #RIPRatanTata#Legend#EndOfAnEra”

News and Tips

@NewsAndTipsNT · Post #4028 · 27.01.2026 г., 02:42

My brother Pavel Durov! 💪 In a world where governments are tightening their grip on our freedoms, big respect to Pavel Durov, the unbreakable force behind Telegram! This man is a true fighter: exiled from Russia for refusing to sell out user data, building an empire on privacy and free speech, and now calling out the EU’s “war against privacy” with their impossible rules that punish innovation. He’s warning us we’re running out of time to save the free internet from a dystopian nightmare of surveillance and censorship. Even after his arrest in France and being blocked from speaking at freedom forums, he stands firm, removing harmful content without compromising principles. Pavel, you’re a legend and you are inspiring entrepreneurs and rebels everywhere to never back down. You are a dear friend and a loyal brother and I stand alongside you all the way 100%! #PavelDurov#FreeSpeechWarrior#Telegram#Legend - Conor McGregor

12
ПретходнаСтраница 1 од 2Следна