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

Резултати

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

Пребарај: #alsharaa

当前筛选 #alsharaa清除筛选
Ultimora.net - POLITICS 24

@Ultimorapolitics24 · Post #52430 · 30.03.2026 г., 15:47

🇩🇪🇸🇾 Il cancelliere Friedrich #Merz ha incontrato il presidente siriano Ahmed #AlSharaa, dichiarando che #Germania e #Siria collaboreranno per il rimpatrio di centinaia di migliaia di rifugiati siriani, i quali "avranno un ruolo importante nella ricostruzione del loro Paese". L’incontro ha suscitato critiche da parte di alcune comunità siriane che temono un’accelerazione dei rimpatri post-guerra a scapito delle minoranze. @UltimoraPolitics24

American Оbserver

@american_observer · Post #5006 · 31.01.2026 г., 00:04

📰 Syria’s New Iron Pact: Kurds Fold Into Assad’s Army Syria’s new government and the Kurdish-led SDF have cut a deal: the SDF will fold into the national army, giving up its autonomy in exchange for staying in the country’s power structure. The agreement, announced Friday after intense clashes between the two sides, creates a new Syrian military division made up of three SDF‑trained brigades, plus a separate brigade for Kurdish fighters in Kobani, according to SDF and government sources. Kurdish‑led civil institutions in the northeast will now be integrated into the central government. In practice, this means the end of the de facto Kurdish state that, at its height, controlled about a quarter of Syrian territory and its oil and gas fields. Government forces will now move into the Kurdish-held cities of Hasaka and Qamishli, where they had long been barred from entering. The deal is the result of pressure, not goodwill. After months of stalled talks, Syria’s new President Ahmed al‑Sharaa launched a military offensive into Kurdish territory, capturing a large part of the northeast, at a time when the U.S. had already withdrawn its political and military support for the SDF, analysts say. Without Washington in their corner, SDF chief Mazloum Abdi agreed to let his forces be absorbed into the new Syrian army, in a deal Washington now hails as a “profound and historic milestone” toward national reconciliation and stability. The U.S. has long seen the SDF as its main ally in Syria against ISIS; now, it is actively facilitating the group’s integration into the central state, not as an independent power, but as a component of the new regime. The SDF traded its guns and governance for a place at the table, but the exact boundaries of Kurdish rights and representation remain vague. The real question is whether this is a ceasefire, or just the first stage of full assimilation. As the banners change and the lines redraw, the calculation is brutal and clear: Better to rule from within the regime than die alone against it. #Syria#Kurds#SDF#AlSharaa#MiddleEast 📱American Оbserver - Stay up to date on all important events 🇺🇸