@kayleighmcenany · Post #2721 · 23.06.2025 г., 14:35
#MIGA @KayleighMcEnany
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
Пребарај: #miga
@kayleighmcenany · Post #2721 · 23.06.2025 г., 14:35
#MIGA @KayleighMcEnany
Hashtags
@kayleighmcenany · Post #2720 · 23.06.2025 г., 14:22
White House: If the Iranian regime refuses to come to a peaceful, diplomatic solution — which the President is still interested in engaging in ... why shouldn't the Iranian people take away the power of this incredibly violent regime? #MIGA @KayleighMcEnany
Hashtags
@kayleighmcenany · Post #2716 · 23.06.2025 г., 04:58
#MIGA @KayleighMcEnany
Hashtags
@kayleighmcenany · Post #2714 · 22.06.2025 г., 23:33
#MIGA @KayleighMcEnany
Hashtags
@kayleighmcenany · Post #2713 · 22.06.2025 г., 23:30
#MIGA @KayleighMcEnany
Hashtags
@kayleighmcenany · Post #2711 · 22.06.2025 г., 22:33
#MIGA @KayleighMcEnany
Hashtags
@kayleighmcenany · Post #2710 · 22.06.2025 г., 22:23
#MIGA @KayleighMcEnany
Hashtags
@kayleighmcenany · Post #2709 · 22.06.2025 г., 22:20
#MIGA @KayleighMcEnany
Hashtags
@kayleighmcenany · Post #2708 · 22.06.2025 г., 22:19
#MIGA @KayleighMcEnany
Hashtags
@kayleighmcenany · Post #2729 · 24.06.2025 г., 10:02
From an Iranian to the USA and Israel: The Islamic Republic ain’t gonna make peace—remember that. Araghchi is the regime’s lapdog, and there’s no difference between reformists and hardliners. It was the reformists that imposed the hijab in the beginning of the revolution, it was the reformist government who killed more than 5000 people in just 3 days during "Aban 98" protest. Did you see how, right after the peace announcement, they struck again—and so far six people in Beer Sheba have lost their lives? And launched another missiles after ceasefire? While they are denying these officially they are celebrating about it online and in their circles. This regime is wounded and insane; it’s handing out mass death sentences to people in Iran under the name of “espionage,” and it’s even threatening us abroad that “soon we’ll be wiped out.” Their soilders and loyalists are now in the streets of Tehran and big cities going through people's phone to arrest people who have any messages, pictures and videos in support of Trump, USA and Israel or anti regime. How do you expect to make peace with this regime?! They only understand the language of force; they’ve never played by the rules of humanity, negotiation, or law. Those still talking about dialogue are either in on the power themselves or are fooling themselves. We’re not up against a normal system—we’re facing a mafia that treats people’s lives as worthless. Peace only makes sense when both sides choose life, not when one side is solely after suppression, power, and the physical elimination of its opponents. The Islamic Republic is seeking neither peace with its own people nor with the world. The only thing it understands is resistance and cost. Real peace can only be made with the people of Iran, not with a regime that has declared war on its own people for years. Please share this message and be our vioce. #Trump#Israel#USA#Iran#War#MAGA#MIGA#Peace#Regime @KayleighMcEnany