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

Пребарај: #c4ca

当前筛选 #c4ca清除筛选
EU in Kazakhstan 🇪🇺🇰🇿

@euinkazakhstan · Post #1766 · 26.03.2026 г., 06:26

Operations Steering Committee of the EU Global Gateway’s Connectivity for Central Asia #C4CA project brought together consortium partners from Lithuania (CPVA), Latvia (CFCA), Estonia (EGA), Finland (HAUS), and France (Expertise France) in Bishkek, alongside the EU Delegations of Kazakhstan and Kyrgyzstan. As part of the Soft Pillar of the Team Europe Initiative on Digital Connectivity, the meeting reviewed first-year results and outlined priorities for the next phase, focusing on digital connectivity, digital economy development, and reducing connectivity gaps in Central Asia. The project delivered key outputs, including country assessments, digital ecosystem mapping, regional events during ICT Week in Uzbekistan and Digital Bridge, and study visits to Europe, Lithuania, and Finland on cybersecurity and the aerospace sector, in coordination with Central Asian stakeholders.

Hashtags

EU in Kazakhstan 🇪🇺🇰🇿

@euinkazakhstan · Post #1632 · 21.11.2025 г., 08:55

SpaceLab at Space Tech Forum, Germany 🚀 From 18–20 November 2025, SpaceLab represented Central Asia at the Space Tech Forum in Bremen, Germany, with support from the EU’s Global Gateway Connectivity for Central Asia – Soft Pillar program. At one of Europe’s largest space tech and aerospace events, SpaceLab established new contacts in the European space market, raised awareness of Central Asian innovative services among European industry players, and helped spark interest in the region on the international stage. The participation also contributed to strengthening cooperation between the #EuropeanUnion and #CentralAsia in the space sector and helped position SpaceLab and the broader Central Asian space community as a credible emerging player in the 🌍global space ecosystem. #SpaceTechForum#GlobalGateway#C4CA#EU4CA