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

Резултати

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

Пребарај: #ism

当前筛选 #ism清除筛选
Shadow Traders Fx

@shadowtraderfx · Post #4326 · 03.11.2025 г., 11:38

📰Top News and Events for the Upcoming Week (November 4–10 November, 2025) for Gold and Forex Hey traders! 👋 This week, gold and forex markets are centered on major US data including ISM Services PMI, trade balance, jobless claims, and factory orders, plus RBA rate decision and Eurozone inflation figures. With Fed policy in spotlight post-PCE, sticky inflation could delay cuts and strengthen USD, capping gold upside. Yet, dovish surprises or global weakness (e.g., soft Eurozone) may revive safe-haven demand. Key pairs like EUR/USD, GBP/USD, and USD/JPY face swings from central bank signals and jobs previews. Here’s a day-by-day breakdown for your trades – let’s get ready! 📈 ✉️Follow @shadowtraderfx for more! ✅ Tuesday, November 4, 2025 📎Gold: US ISM Services PMI (10:00 ET) kicks off – contraction below 50 boosts safe-haven flows, lifting gold. 📎Forex: PMI impacts DXY; weak reading favors EUR/USD and GBP/USD gains. USD/JPY steady amid yen caution. Key event: ISM Services PMI – a miss weakens USD majors. 💡 Tip: Mid-morning volatility; enter on confirmed breaks. ✅ Wednesday, November 5, 2025 📎Gold: US Trade Balance (8:30 ET) and JOLTS Job Openings (10:00 ET) in focus – wider deficit or high openings signal labor strength, pressuring gold via USD resilience. 📎Forex: JOLTS drives jobs narrative; strong print drops EUR/USD support. GBP/USD eyes UK data spillover. Key event: JOLTS Job Openings – above forecasts bolsters USD. 💡 Tip: Labor data overlap – tighten stops for whipsaws. ✅ Thursday, November 6, 2025 📎Gold: RBA rate decision (overnight) and US initial jobless claims (8:30 ET) dominate – steady RBA with dovish tilt weakens AUD, supporting gold; rising claims erodes USD. 📎Forex: RBA impacts AUD/USD heavily; claims lift majors like EUR/USD. USD/JPY risks yen rebound on risk-off. Key event: US Initial Jobless Claims – rise fuels Fed cut bets. 💡 Tip: Asia-US session bridge – watch for RBA presser cues. ✅ Friday, November 7, 2025 📎Gold: Eurozone CPI Flash (5:00 ET) and US factory orders (10:00 ET) wrap week – hotter Euro inflation pressures ECB, indirectly aiding gold; weak US orders boost dovish vibes. 📎Forex: CPI moves EUR/USD; soft factory orders weaken DXY. GBP/USD consolidates; USD/JPY eyes BoJ fallout. Key event: Eurozone CPI Flash – above target caps euro rally. 💡 Tip: Month-start flows – scale out early to manage gaps. ✅ Saturday & Sunday, November 8–9, 2025 (Markets Closed) 📎Gold & Forex: Digest RBA, US jobs data, and Euro CPI. Forecast: Gold gains on dovish signals; DXY dips if claims rise. 💡 Tip: Review for next week’s FOMC minutes and CPI. ✅ Monday, November 10, 2025 📎Gold: US wholesale inventories (10:00 ET) starts fresh – buildup hints at economic slowdown, lifting gold as safe-haven. 📎Forex: Inventories subtle for DXY; EUR/USD tests recent highs. Low-volume pre-major events. Key event: US Wholesale Inventories – surprise drawdown supports USD. 💡 Tip: Quiet open; position for mid-week catalysts. 🔎 Weekly Summary: ISM Services, JOLTS, and RBA decision lead – strong US labor data could hawkish-shift Fed expectations, strengthening USD, but weak Euro CPI fuels gold rallies. Forex pairs volatile, so risk management! Join us winning team 💬 📱Stay updated with @shadowtraderfx #Gold#Forex#ISM#RBA#CPI#XAUUSD#EURUSD