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

Резултати

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

Пребарај: #erosion

当前筛选 #erosion清除筛选
Interesting Planet 🌍

@interesting_planet_facts · Post #892 · 11.10.2025 г., 15:11

🌎 Perched atop a limestone cliff, the Italian town of Civita di Bagnoregio is slowly crumbling away as erosion eats at its base. Only about 12 people reside year-round, and the settlement is accessible by a pedestrian bridge spanning a deep valley. ✨ #geography⚡#architecture⚡#erosion 👉subscribe Interesting Planet 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #239 · 15.09.2025 г., 03:12

🌍 Some coastlines in Alaska lose up to 20 meters of land each year from a mix of sea ice loss, stronger storms, and thawing ground, making it one of the fastest-eroding coastlines worldwide. ✨ #erosion⚡#coastline⚡#climate⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #394 · 20.10.2025 г., 12:31

🌍 Some sea stacks—towering rock columns near coastlines—form when waves erode cliffs, leaving only isolated pillars. Ireland’s Dun Briste sea stack stands 50 meters above the Atlantic. ✨ #coastline⚡#erosion⚡#geology⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #539 · 27.12.2025 г., 12:31

🌍 In some places, rising sea levels have pushed salty ocean water far inland, turning once-fresh coastal farmland into wetlands and forcing communities to change how and where they grow crops. ✨ #erosion⚡#sea-level ⚡#climate⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #319 · 01.10.2025 г., 15:31

🌍 In some places, coastal cliffs are vanishing so quickly that entire villages have moved inland within a single generation, as sea level rise and stronger storms speed up the erosion. ✨ #erosion⚡#coastlines⚡#climate⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #580 · 19.01.2026 г., 12:31

🌍 In some low-lying Pacific islands, entire villages have relocated inland as coastal erosion worsens from rising sea levels, erasing beaches and farmland within a single generation. ✨ #erosion⚡#sea-level ⚡#islands⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #504 · 09.12.2025 г., 20:31

🌍 Rainwater can carve entire underground labyrinths in karst landscapes, creating vast networks of caves, tunnels, and sinkholes—some so deep and complex that new passages are still being found today. ✨ #caves⚡#karst⚡#erosion⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #472 · 23.11.2025 г., 20:31

🌍 Coastal erosion is eating away cliffs and beaches so fast in some places that detailed maps need updating every year, with new shorelines appearing and disappearing before our eyes. ✨ #coastlines⚡#erosion⚡#mapping⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #618 · 07.02.2026 г., 12:31

🌍 In the last 30 years, parts of Louisiana’s coast have lost over 2,000 square kilometers of land to erosion and rising seas—an area bigger than many cities, disappearing into open water. ✨ #erosion⚡#sea-level ⚡#wetlands⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #395 · 20.10.2025 г., 15:31

🌍 In some regions, sea level rise combines with sinking land, making coastal erosion even faster. This double impact is shrinking important wetlands and salt marshes much quicker than before. ✨ #erosion⚡#wetlands⚡#sea-level ⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #701 · 25.04.2026 г., 20:31

🌍 Coastal erosion now removes up to 24 square meters of land per meter of shoreline in some parts of West Africa each year, forcing whole fishing villages to move further inland. ✨ #coastlines⚡#erosion⚡#sea-level ⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #432 · 03.11.2025 г., 20:31

🌍 Satellite data shows that some coastlines have retreated by over 50 meters in just a decade, as rising sea levels and stronger storms rapidly reshape shores across the globe. ✨ #erosion⚡#sea-level ⚡#coastlines⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

12
ПретходнаСтраница 1 од 2Следна