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

Резултати

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

Пребарај: #dariadugina

当前筛选 #dariadugina清除筛选
BadVolf

@BadvolfNews · Post #260 · 22.08.2022 г., 15:00

From Alexander Dugin: “As you all know, as a result of a terrorist attack carried out by the Nazi Ukrainian regime, on August 20, while returning from the Tradition festival near Moscow, my daughter Daria Dugina was brutally killed by an explosion in front of my eyes. She was a beautiful Orthodox girl, a patriot, a military correspondent, an expert on the central channels, and a philosopher. Her speeches and reporting have always been profound, grounded and restrained. She never called for violence and war. She was a rising star at the beginning of her journey. The enemies of Russia meanly, stealthily killed her ... But we, our people, cannot be broken even by such unbearable blows. They wanted to crush our will with bloody terror against the best and most vulnerable of us. But they won't get it. Our hearts yearn for more than just revenge or retribution. It's too petty, not Russian. We only need our Victory. My daughter laid her maiden life on her altar. So win, please! We wanted to raise her to be smart and a hero. Let it inspire the sons of our Fatherland to the feat even now. Farewell to Daria Dugina (Platonova) - a civil memorial service - will take place on August 23 at the Ostankino Television Center at 10 am. Alexander Dugin #ECM#DariaDugina

Sos Donbass

@sos_donbass · Post #688 · 23.08.2023 г., 06:28

Un verset du journal de Darya Dugina, qu'elle a tenu pendant les trois dernières années de sa vie. Certaines de ses citations sont utilisées dans le livre, qui est publié à titre posthume « Marais et hauteurs de mon cœur. Journal" : Partir à l'heure et tranquillement, Sans douleur intense et cris forts, Aucune offense et aucun regret Mots vides et doutes. Partir doucement et calmement : Fermer les yeux pour rester un guerrier, Ayant réussi à voir ses proches… Pardonnez-moi, je dois partir. #dariadougina#poemes#dariadugina

Sos Donbass

@sos_donbass · Post #1296 · 19.08.2024 г., 16:26

🗣️ Nouvelles de SOS DONBASS, prononcées par le président de l’association Vincent Perfetti: ▫️ Compte bancaire / reprise de l’activité ▫️Action LA RUSSIE N’EST PAS MON ENNEMI ▫️ Commémoration de Daria Douguina ▫️ Aide à la population de Koursk #dariadouguina#dariadugina#sosdonbass#donbass#russie#ukraine#solidarite