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

Резултати

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

Пребарај: #city

当前筛选 #city清除筛选
Pro Analysis

@proanalysistrader · Post #28555 · 18.03.2025 г., 08:15

#CITY/USDT analysis : #CITY has broken out and retested the 200 Exponential Moving Average (EMA). It is currently consolidating above the 200 EMA. The price is expected to bounce back from this level and resume its upward momentum to test higher levels. TF : 1H Entry : $1.107 Target : $1.160 SL : $1.075

Hashtags

Pro Analysis

@proanalysistrader · Post #28501 · 26.02.2025 г., 11:50

#CITY/USDT analysis : #CITY is currently in a downtrend, establishing new lows. The price is anticipated to retest the resistance zone before potentially reversing from there to resume bearish momentum and test lower levels. TF : 4h Entry : $1.220 Target : $1.083 SL : $1.300

Hashtags

Pro Analysis

@proanalysistrader · Post #28384 · 12.01.2025 г., 11:29

#CITY/USDT analysis : #CITY has broken below the support levels, forming lower lows (LLs) and lower highs (LHs) while trading below the 200 EMA. The price is expected to maintain its bearish momentum and test lower levels. TF : 2H Entry : $1.826 Target : $1.715 SL : $1.903

Hashtags

Pro Analysis

@proanalysistrader · Post #27908 · 06.09.2024 г., 14:16

#CITY/USDT analysis : #CITY is presently in a downtrend, trading below the 200 EMA. The price is currently consolidating above support levels. It is expected to be breached by the price soon and will continue its bearish momentum on lower time frames to test previous lows. Wait for a break of the $1.945 level to initiate a short position. TF : 1H Entry : $1.945 Target : $1.853 SL : $2.005

Hashtags

123•••10•••1314
ПретходнаСтраница 1 од 14Следна