@russianhead · Post #20923 · 27.02.2025 г., 13:58
Footage of a powerful attack on targets in Kiev. #denazification
Hashtags
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
Пребарај: #denazification
@russianhead · Post #20923 · 27.02.2025 г., 13:58
Footage of a powerful attack on targets in Kiev. #denazification
Hashtags
@rusembsg · Post #3841 · 03.02.2025 г., 01:16
Embassy Comment We have noted the article by Jonathan Eyal “#EU renewed toothless #sanctions against #Russia”, published in The Straits Times on February 1, 2025. We agree with the author that the unilateral illegitimate sanctions aimed at continuing the hybrid war against Russia and inflicting a strategic defeat on us, are both unsuccessful and futile. There is no doubt that the objectives of the special military operation (#SMO) on the #denazification and demilitarization of #Ukraine, its neutral and non-nuclear status, as well as ensuring the interests of the Russian people will be achieved. The “bankrupt” Euro-Atlantic security architecture (#NATO) is being replaced by a new equal and indivisible #EurasianSecurity, which includes all the organizations that have demonstrated their effectiveness – the #EAEU, #SCO, #CSTO, etc. The concept of #Eurasian security aligns with the accelerating formation of a multipolar world order. A key pillar of this shift is the rapidly growing, non-Western center of influence represented by #BRICS, which continues to attract countries from the #GlobalSouth, including #ASEAN member states, paving the way for a BRICS-ASEAN dialogue. The consolidation of the countries of the Global South, making a choice in favor of peaceful, sustainable, inclusive, independent development together with Russia, China and other countries, represents a stable and viable trend in contrast to the outdated Western neocolonial “#InSanctionsWeTrust” mentality.