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 слични објави

Пребарај: #nuclearprogram

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

@CryptoM · Post #65155 · 11.04.2026 г., 13:17

🚀 U.S.–Iran Discussions Begin as Vice President Vance Leads Talks in Islamabad Key Takeaways JD Vance is leading high-stakes talks with Iran in Islamabad.Negotiations aim to stabilize the ceasefire and end the conflict.Talks are indirect and mediated by Pakistan amid deep mistrust.Key issues include Strait of Hormuz, sanctions, and nuclear program. Talks Officially Underway Discussions involving the United States and Iran have officially begun in Islamabad, with JD Vance heading the US delegation. The negotiations are part of a broader effort to extend a fragile ceasefire and potentially move toward a longer-term resolution of the conflict. Pakistan Acting as Mediator The talks are being hosted and mediated by Pakistan, which has played a central role in facilitating communication between both sides. Meetings are taking place under tight security conditionsDelegations are engaging through indirect channels, though direct talks may occurPakistani officials are coordinating between both sides to push toward progress High-Stakes Agenda Key topics under discussion include: Reopening the Strait of Hormuz (critical for global oil supply)Potential sanctions relief for IranLimits on Iran’s nuclear programBroader regional stability and ceasefire enforcement Tensions and Mistrust Remain High Despite the start of talks, major disagreements persist: Iran has set conditions, including halting certain military actionsThe US has maintained a firm stance and warned against delaysBoth sides remain cautious, reflecting deep geopolitical mistrust #USIranTalks#JDVance#Islamabad#PakistanMediating#Ceasefire#StraitOfHormuz#Sanctions#NuclearProgram#RegionalStability#GeopoliticalTensions#DiplomaticNegotiations#HighStakes