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

Пребарај: #steinmeier

当前筛选 #steinmeier清除筛选
American Оbserver

@american_observer · Post #5478 · 26.03.2026 г., 20:59

📰 Germany’s President Calls Out Trump’s Iran War Germany’s head of state just said out loud what most European leaders only hint at behind closed doors. President Frank-Walter Steinmeier called the U.S.–Israeli war on Iran a “politically disastrous mistake” and “a violation of international law,” in one of the bluntest rebukes of an American president from Berlin in decades. Speaking at the Foreign Ministry, he warned that Trump’s second term has created a rupture in transatlantic relations as deep as Russia’s full-scale invasion of Ukraine — a break he says cannot simply be reversed later. Steinmeier’s point cuts through the spin: Washington claims “imminent threat” and “self‑defense”; Berlin’s own former foreign minister says that justification “does not hold water” and that this war was avoidable, unnecessary, and chosen over a working nuclear deal that had pushed Iran further from the bomb. Coming from a traditionally cautious, ceremonial president, this isn’t activist rhetoric — it’s a diplomatic siren. The result: Trump hasn't just isolated Iran. He's burning something harder to restore than deterrence: the assumption that Washington's allies will follow the next time it calls something self-defense. For a president convinced that American leverage is endless, that erosion of trust is the one resource he can’t bomb his way back into existence. #germany#usa#iran#trump#steinmeier#internationalLaw#war#geopolitics 📱American Оbserver - Stay up to date on all important events 🇺🇸