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

Резултати

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

Пребарај: #ussanctions

当前筛选 #ussanctions清除筛选
Venezuelanalysis

@venanalysis · Post #2012 · 24.06.2025 г., 19:05

📑🖊 OPINION | Demonizing Nicolás Maduro: Fallacies and Consequences In his latest opinion piece, Steve Ellner argues that saying 'I oppose sanctions' while criticizing the Maduro government’s policies as if they were separate issues is misleading. He stresses that sanctions and domestic policy are deeply interconnected, and that ignoring this relationship reinforces regime-change narratives and undermines international solidarity. 🔗 Read the full opinion piece here: https://shorturl.at/3J2tg #NicolasMaduro#Sanctions#USSanctions

Venezuelanalysis

@venanalysis · Post #1856 · 20.01.2025 г., 18:02

The fight over CITGO intensifies as the Delaware auction restarts amid low bids, creditor disputes, and parallel lawsuits. Behind the corporate scramble lies a deeper story of US sanctions and opposition mismanagement, threatening what Venezuela calls the ‘theft of the century.’ Watch the full video to learn more! #venezuela#citgo#sanctions#ussanctions

Venezuelanalysis

@venanalysis · Post #1886 · 21.02.2025 г., 19:03

📝 INTERVIEW | Descendents of Cacique Ähuänumä: The 4F Huo̧ttö̧ja̧ Commune In Venezuela’s Amazonas state, the February 4 Huo̧ttö̧ja̧ Commune brings together Indigenous governance and communal socialism. With collective land tenure and assembly-based decision-making, its people continue a tradition of resistance. The Life Plan is central to their way of life. Integrating ancestral wisdom and modern education, it dictates when to plant, hunt, and harvest—ensuring harmony with nature. 🔗 Read the latest interview from VA’s Communal Resistance Series here: https://shorturl.at/B37yt #CommunalandWorkingClassResistance#Communes#IndigenousPeoples#USSanctions

Crypto M - Crypto News

@CryptoM · Post #64621 · 09.04.2026 г., 11:37

🚀 Iran Utilizes Cryptocurrency for Strait of Hormuz Passage Fees Iran is employing cryptocurrency to collect fees from ships passing through the Strait of Hormuz. According to NS3.AI, TRM highlighted that the rapid nature of digital currency transactions and their operation outside the U.S. banking system complicate efforts by the U.S. to freeze or block these payments in real time. #Iran#Cryptocurrency#StraitOfHormuz#DigitalCurrency#Shipping#USSanctions#Blockchain