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

Резултати

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

Пребарај: #strange

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

@cosmomyst · Post #463 · 28.10.2025 г., 22:21

🪐 In the spiral galaxy NGC 3310, astronomers have observed a rare "gamma-ray burst afterglow," the fading embers following one of the universe’s brightest explosions. This lingering glow, seen in visible light and X-rays, lets scientists track how shockwaves from the original burst plow through space, revealing clues about the powerful forces unleashed when massive stars die. ✨ #gamma-ray-bursts ⚡#strange-cosmic-phenomena ⚡#galaxies⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​

"Nunca habíamos visto nada igual..." Algo aterrador está sucediendo en Estados Unidos (2025) Únase a nosotros: https://anon.news 🔘En este video, el mundo quedó atónito ante la repentina aparición de un elegante monolito metálico en los remotos desiertos de Utah. Alto y silencioso, el objeto guardaba un asombroso parecido con los monolitos de 2001: Odisea del Espacio, y luego, con la misma incógnita, desapareció. Desde entonces, han aparecido docenas de estructuras similares en lugares de todo el mundo, desde las montañas nevadas de Rumania hasta las playas de California, las selvas de Colombia y los tejados de las ciudades europeas. ¿Son instalaciones artísticas, engaños elaborados o algo más enigmático? Cada monolito parece surgir sin previo aviso, a menudo en lugares de difícil acceso, y sin que nadie se atribuya la responsabilidad. Algunos son espejados y minimalistas; otros están grabados con símbolos crípticos. El fenómeno ha desatado la intriga mundial, generando teorías de conspiración, videos virales y un auge en el debate especulativo sobre la vida extraterrestre, las sociedades secretas y la conciencia colectiva. #unexplained#strange#phenomena @EndTimesProductions@Jaymez

Universe Mysteries 🪐

@cosmomyst · Post #564 · 17.12.2025 г., 22:21

🪐 One of the most mysterious cosmic events are gamma-ray bursts, or GRBs—brief, intense flashes of high-energy light detected from distant galaxies, like the spiral galaxy NGC 2770. In 2008, NGC 2770 hosted the rare GRB 080319B, which was so bright that, for about 30 seconds, it was visible to the naked eye from Earth despite being 7.5 billion light-years away, making it the most distant object ever seen without a telescope. ✨ #gamma-ray-bursts ⚡#strange-phenomena ⚡#NGC2770⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​

Universe Mysteries 🪐

@cosmomyst · Post #507 · 19.11.2025 г., 12:21

🪐 In the star-forming region W51, astronomers have found “masers”—natural lasers made of microwaves—blasting out intense, focused beams from clouds of water and methanol molecules. These cosmic masers shine thousands of times brighter than any similar emission in our solar system and act like celestial signposts, marking areas where massive new stars are being born within dense, hidden clouds of gas. ✨ #strange⚡#phenomena⚡#maser⚡#starbirth⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​