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

Пребарај: #asmara

当前筛选 #asmara清除筛选
Addis Standard

@addisstandardeng · Post #22009 · 13.04.2026 г., 08:01

News: #Eritrea’s President Isaias meets #China’s Horn of Africa envoy, calls for expanded role Eritrean President #Isaias_Afwerki met with Hu Changchun, China’s Special Envoy to the Horn of Africa, on 10 April 2026 at the Denden Guest House in #Asmara. According to Information Ministry of Eritrea, President Isaias reiterated Eritrea’s readiness to strengthen its engagement with China, emphasizing the need for a more prominent Chinese role in global & regional affairs amid what he described as heightened instability. He also highlighted Africa’s natural & human resources, underscoring what he called China’s expected contribution to their development. Ambassador Hu, for his part, expressed Beijing’s readiness to deepen its strategic partnership with Eritrea and to align development efforts in support of peace and stability in the Horn of Africa, the ministry said. Eritrea’s Foreign..... https://www.facebook.com/AddisstandardEng/posts/pfbid0a26QnfAYtXCvNLrMw4DJ9cPu2Qoa9fcMnhd8HospCtDC5JThQZJdxGCxoe1iWwWMl

Addis Standard

@addisstandardeng · Post #21496 · 23.02.2026 г., 08:32

News: #Saudi deputy foreign minister meets #Ethiopian FM week after Isaias talks in Asmara Saudi Arabia’s Vice Minister of Foreign Affairs, Waleed A. M. Elkhereiji, met with Ethiopia’s Minister of Foreign Affairs, Gedion Timothewos, in Addis Abeba, a week after holding talks with #Eritrean President #Isaias Afwerki in #Asmara. According to a statement from the Ethiopian Ministry of Foreign Affairs, the two officials discussed the “strong and longstanding bilateral relations” between Ethiopia and the Kingdom of Saudi Arabia, underscoring the importance of elevating ties to “a new high.” They also exchanged views on regional peace & security issues of mutual interest. Ethiopia’s Minister of Foreign Affairs offered no additional information in the statement. The meeting comes a week after Saudi Vice Foreign Minister Waleed A. M. Elkhereiji held talks in Asmara with Eritrean President... Read more: https://addisstandard.com/saudi-deputy-foreign-minister-meets-ethiopian-fm-week-after-isaias-talks-in-asmara/

Addis Standard

@addisstandardeng · Post #21370 · 11.02.2026 г., 12:55

News: #Amhara security bureau alleges #TPLF, #Eritrea involvement in ongoing conflicts The Amhara Regional State Peace and Security Bureau has alleged that ongoing conflicts in the Amhara region and elsewhere in #Ethiopia are receiving what it described as “leadership and logistical support from #Mekelle and #Asmara,” referring to the Tigray People’s Liberation Front (TPLF) and Eritrean government. In a statement released yesterday, the bureau said the public “must understand the reality” that the fighting is not only against groups it characterized as “extremists” but also involves what it described as internal and external actors. The statement further alleged that a group seeking control over the areas of #Wolkait, #Telemt, and #Raya had assigned what it called a mission to “internal extremist forces” and was mobilizing them to advance that objective. According to the bureau, the strategy aims to create conflicts across various zones and districts to... Read more: https://addisstandard.com/?p=55148