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

Пребарај: #ecf

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

@addisstandardeng · Post #21104 · 17.01.2026 г., 08:32

News: #IMF approves $261 million disbursement to #Ethiopia, cites stronger macroeconomic performance The International Monetary Fund (IMF) has approved the immediate release of US$261 million to Ethiopia under its Extended Credit Facility (#ECF), following the completion of the fourth review of the country’s reform program. The decision, the Fund said, reflects “stronger-than-anticipated macroeconomic outcomes and overall performance broadly in line with program commitments.” In a statement issued on 16 January 2026, the IMF said the Executive Board’s decision under the 48-month ECF arrangement will support Ethiopia’s balance of payments and fiscal financing needs. The disbursement brings total funding released under the program to approximately US$2.183 billion (SDR 1.6 billion). To strengthen the foreign exchange market, the IMF introduced a new performance criterion setting a zero limit on foreign exchange intervention outside of auctions. Read more: https://addisstandard.com/?p=54630

Addis Standard

@addisstandardeng · Post #21279 · 02.02.2026 г., 13:04

#Ethiopia: National Bank to phase out #gold premium, open purchases to private banks; #IMF warns exchange rate challenges hinder private investment The National Bank of Ethiopia (#NBE) is overhauling its gold transaction procedures to reduce risks to its balance sheet and curb distortions in the banking sector, according to the International Monetary Fund’s (IMF) latest review of Ethiopia’s Extended Credit Facility (#ECF) program. Under the new framework, the premium above international gold prices currently paid to miners will be phased out, while private banks will be allowed to participate in gold purchases. The NBE plans to develop a detailed implementation roadmap based on a study expected by the end of March 2026. In the meantime, quality control will be strengthened through expanded and improved gold testing at all purchasing sites. The central bank also intends to prepare a long-term exit plan from the gold market by the end of December 2026,... Read more: https://addisstandard.com/?p=54903