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

Резултати

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

Пребарај: #maritimeblockade

当前筛选 #maritimeblockade清除筛选
Crypto M - Crypto News

@CryptoM · Post #65224 · 12.04.2026 г., 04:24

🚀 U.S. President Trump Considers Maritime Blockade Against Iran On April 12, U.S. President Donald Trump posted on Truth Social about a potential maritime blockade against Iran. According to BlockBeats, Trump suggested this measure if Iran does not make concessions. The statement highlights ongoing tensions between the United States and Iran, with the possibility of escalating actions if diplomatic solutions are not reached. #Trump#Iran#MaritimeBlockade#USIranTensions#Diplomacy#TruthSocial#TrumpStatement#IranConcessions

Crypto M - Crypto News

@CryptoM · Post #65389 · 13.04.2026 г., 04:28

🚀 U.S. Maritime Blockade Could Impact Iran's Oil Exports, Says Garrett Jin Garrett Jin has indicated that a U.S. maritime blockade around the Strait of Hormuz could potentially reduce Iran's oil export income by approximately 1.7 million barrels per day. According to NS3.AI, Jin noted that the blockade primarily targets Iranian ports rather than completely closing the strait, allowing for the possibility of third-party transshipment. However, he cautioned that this measure might not be sufficient to resolve the ongoing conflict. #US#MaritimeBlockade#Iran#OilExports#StraitOfHormuz#GarrettJin#EconomicImpact#NS3AI#Conflict

Crypto M - Crypto News

@CryptoM · Post #65394 · 13.04.2026 г., 04:52

🚀 Strait of Hormuz Traffic Halts Following U.S. Maritime Blockade All maritime traffic through the Strait of Hormuz has reportedly ceased after U.S. President Donald Trump declared a maritime blockade via social media. According to NS3.AI, information from British sources, as reported by CCTV News, indicated that the blockade had been in place for several hours. While traffic was still feasible on the 12th, at least two vessels attempting to exit the strait reversed course. Tanker traffic had seen a slight uptick on the 11th before declining on the 12th. #StraitOfHormuz#MaritimeBlockade#USPresident#DonaldTrump#TankerTraffic#CCTVNews#NS3AI#MaritimeTraffic