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

Резултати

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

Пребарај: #hazard

当前筛选 #hazard清除筛选
Universe Mysteries 🪐

@cosmomyst · Post #316 · 23.09.2025 г., 12:21

🪐 Asteroid (2007) FT3 is a large near-Earth object, measuring about 340 meters across, that periodically comes close enough for astronomers to classify it as potentially hazardous. Its orbit is tracked because, though it poses no immediate danger, even objects this size could cause severe destruction if they ever collided with Earth—showing why scientists keep careful watch on these silent travelers. ✨ #asteroids⚡#hazard⚡#monitoring⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries ​

Universe Mysteries 🪐

@cosmomyst · Post #170 · 22.08.2025 г., 03:11

🪐 The asteroid (33342) 1998 WT24, about half a kilometer wide, regularly makes close approaches to Earth, coming inside the orbit of Mercury every few years due to its highly elongated path. Its size and proximity earn it the label "potentially hazardous asteroid," so NASA keeps a close eye on it to ensure its orbit remains safely predictable. ✨ #asteroids⚡#hazard⚡#monitoring⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #92 · 07.08.2025 г., 00:11

🪐 The asteroid 99942 Apophis may get the most headlines, but there are over 2,300 "potentially hazardous asteroids" tracked by NASA's Sentry system, like (410777) 2009 FD and (144898) 2004 VD17. These objects, each large enough to cause serious regional damage if they ever struck Earth, are monitored for changes in their orbits to ensure they pose no imminent threat. ✨ #asteroids⚡#hazard⚡#monitoring⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #105 · 09.08.2025 г., 13:11

🪐 The asteroid (153814) 2001 WN5, roughly 1 kilometer across, will pass exceptionally close to Earth in 2028—only about 248,000 kilometers away, closer than the Moon. Because of its size and fast approach, 2001 WN5 is classified as a "potentially hazardous asteroid," meaning it could cause regional devastation if it ever struck our planet, so astronomers track its orbit with special care. ✨ #asteroids⚡#nearEarth⚡#hazard⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #91 · 06.08.2025 г., 20:11

🪐 The asteroid (99942) 2004 MN4, known as Apophis’s “cousin,” (163899) 2003 SD220, is a mountain-sized space rock that approaches Earth’s orbit about every December. Measuring roughly 1.6 kilometers long, its close passes remind scientists how even asteroids with well-known orbits can periodically come within just a few million kilometers of our planet, earning it a spot on NASA's list of potentially hazardous objects. ✨ #asteroids⚡#hazard⚡#nearEarth⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #458 · 26.10.2025 г., 12:21

🪐 One of the most closely monitored space objects threatening Earth is the asteroid (29075) 1950 DA, a kilometer-wide rock that will come unusually close to our planet in the year 2880. What makes 1950 DA especially concerning is its "rubble pile" structure, where its surface is held together more by weak forces between its grains than by gravity, making its behavior unpredictable if its path changes—so astronomers continually track it for any shift that could bring it closer to Earth in the future. ✨ #asteroid⚡#hazard⚡#monitoring⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​

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