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

Резултати

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

Пребарај: #temperature

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

@interesting_planet_facts · Post #1067 · 24.11.2025 г., 12:11

🌎 The Lut Desert in Iran is one of Earth's most extreme climate zones, recording the hottest surface temperature ever measured—80.8°C in 2005 by satellite. Known as Dasht-e Lut, this salt desert has almost no vegetation or permanent water sources. ✨ #climate⚡#desert⚡#temperature 👉subscribe Interesting Planet 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #161 · 02.09.2025 г., 09:12

🌍 The Lut Desert in Iran holds the record for Earth’s hottest land temperature ever measured from space—an astonishing 80.8°C, far exceeding typical desert heat. ✨ #deserts⚡#temperature⚡#extremes⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Amazing Geography 🌍

@amazingeo · Post #389 · 18.10.2025 г., 20:31

🌍 The world’s largest continental climate zone covers central Eurasia, where summers can reach above 40°C and winters drop below –40°C—a giant temperature swing found nowhere else on Earth. ✨ #climatezones⚡#temperature⚡#Eurasia⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #16 · 10.08.2025 г., 03:12

🌍 Cities often create "urban heat islands," where temperatures are higher than surrounding areas due to concrete, asphalt, and less greenery. This effect can raise cities’ temperatures by several degrees. ✨ #urbanization⚡#temperature⚡#humanimpact⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍

Universe Mysteries 🪐

@cosmomyst · Post #690 · 19.02.2026 г., 22:21

🪐 Uranus stands out as the coldest giant planet in the solar system, with atmospheric temperatures dipping as low as minus 224 degrees Celsius—colder than even Neptune, despite being closer to the Sun. This frigid world is also tipped on its side, with its axis tilted by about 98 degrees, so its poles almost point directly at the Sun during parts of its long, 84-year orbit. ✨ #Uranus⚡#giantplanets⚡#temperature⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​