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

Пребарај: #legends

当前筛选 #legends清除筛选
Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #39958 · 27.10.2025 г., 23:01

Today, exactly 100 years ago on the 28th of October 1925 the mask of Tutankhamun was discovered. There was a legend that those who disturbed the tomb would be cursed, soon after the discovery and disturbance of the tomb certain incidents in wich members of the team started dying made it seem that this legend was true. [read more here] @googlefactss#history#funfact#Egypt#legends

Interesting Planet 🌍

@interesting_planet_facts · Post #1319 · 27.02.2026 г., 12:11

🌎 The legend of Yamata no Orochi comes from ancient Japanese mythology and describes an enormous eight-headed, eight-tailed serpent defeated by the god Susanoo. According to the Kojiki and Nihon Shoki texts from the 8th century CE, Susanoo discovered the creature in Izumo Province and tricked it with sake before slaying it. Archaeological evidence indicates these texts are among Japan’s oldest written records. ✨ #mythology⚡#Japan⚡#legends 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #631 · 26.08.2025 г., 03:22

🌎 Ireland’s legend of the Salmon of Knowledge tells of a magical fish that granted wisdom to whoever tasted it. In Celtic mythology, eating this salmon gave the poet Fionn mac Cumhaill extraordinary wisdom, making him a great hero in Irish folklore. ✨ #mythology⚡#legends⚡#folklore 👉subscribe Interesting Planet ​

Interesting Planet 🌍

@interesting_planet_facts · Post #922 · 17.10.2025 г., 12:11

🌎 On the island of Flores in Indonesia, local legend tells of the Ebu Gogo—small, hairy people said to steal food and mimic speech. In 2003, scientists discovered Homo floresiensis fossils nearby, a tiny ancient human species, fueling debate about whether the myth preserves a memory of real prehistoric encounters. ✨ #legends⚡#anthropology⚡#indonesia 👉subscribe Interesting Planet 👉more Channels ​

🗺🐍Grootslang (Afrikaans and Dutch for “big snake”) is a legendary creature said to dwell in a deep cave in the Richtersveld region of northwestern South Africa, fiercely guarding its diamonds 💎 from treasure seekers. According to myth, the Grootslang was so powerful and cunning that the gods who created Earth decided to split it into two separate species — the elephant🐘 and the snake. 🐍 Yet some Grootslangs, the legends say, escaped into the deepest cave, where they have survived to this day. The cave is filled with diamonds 💎, but no one can reach them — the creature keeps watch day and night. 🌑✨ #Culture#Myths#SouthAfrica#Africa#Legends#Wildlife

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40775 · 11.03.2026 г., 15:04

Flexible glass was a legendary type of glass from ancient Rome. A craftsman is said to have invented it, and it could supposedly bend without breaking. He showed it to Emperor Tiberius, who reportedly asked him to confirm he was the only one who knew how to make it. The emperor then had him executed to prevent the invention from spreading, an early example of planned obsolescence. No known examples survive today. 🏺🪞📜 [Read more] @googlefactss #FlexibleGlass#AncientRome#History#Legends#Innovation

Interesting Planet 🌍

@interesting_planet_facts · Post #757 · 15.09.2025 г., 20:22

🌎 The Mapuche people of southern Chile and Argentina have long told of the mythical “Pillán,” powerful spirits linked to volcanoes and natural disasters. Early European chroniclers in the 16th century recorded beliefs that eruptions were caused by these spirits’ anger. The word “pillán” still appears in many local place names near active volcanoes. ✨ #Mapuche⚡#mythology⚡#volcanoes⚡#legends 👉subscribe Interesting Planet ​

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