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

Пребарај: #drought

当前筛选 #drought清除筛选
Red Nile

@rednile12 · Post #10814 · 20.01.2026 г., 13:25

በ2020ው የዋሽንግተን ረቂቅ የስምምነት ሰነድ አሜሪካ እና ግብፅ እንደ ወጥመድ የተጠቀሙት "DROUGHT" እና "WATER FLOW" ዋሽንግተን ላይ ተደርጎ በነበረው ድርድር የአየር ሁኔታን ተገን አድርገው ግብፅ እና አሜሪካ "Historic Right" የሚለውን የግብፅን የቅኝ ግዛት ትሪክት " #DROUGHT" የሚል ካባ አልብሰው በ2020ው የዋሽንግተን ረቂቅ የስምምነት ሰነድ ውስጥ እንደት እንዳስገቡ እንመልከት ወደ ዋሽግተኑ ረቂቅ የስምምነት ሰነድ ከመሄዳችን በፊት ትራምፕ ጃንዋሪ 16፣ 2026 ላይ “በድርቅ እና ለረጅም ጊዜ ደረቅ ዓመታት ለግብፅ እና ለሱዳን የሚለቀቁ የውሃ ልቀት ሊተነብይ የሚችል ይሆናል” ብሎ ለፍሬንዱ አል ሲሲ የላከውን መልዕክት ስንመረምር መልዕክቱ የተቀዳችው ከረቂቅ ሰነዱ ይሆን🤔? የሚል ጥርጣሬም ያጭራል:: ጥርጣሬውን እንደጥርጣሬ ይዘን👇 በ2020 የዋሽንግተን ረቂቅ ሰነድ ውስጥ የሰፈሩት “ድርቅ” እና “ረዥም ጊዜ ደረቅ ዓመታት” ለሚሉ አባባሎች፤ ኢትዮጵያ አባባሎቹ አደገኛ ወጥመድ ናቸውና ከትርጓሜያቸው ጀምሮ መስተካከል አለባቸው ስትል ተከራክራለች:: 🔻Continued Below @rednile12

Hashtags

Addis Standard

@addisstandardeng · Post #21904 · 01.04.2026 г., 13:07

‘Sharing is off the table’ as #drought reshapes the lives of #Ethiopia’s pastoralists Pastoralists in Ethiopia’s #Somali region say that worsening drought is eroding traditional systems of sharing that once helped communities survive. Historically, Somali pastoralists survived drought through strong social networks. These Indigenous climate adaptations were built on an intricate system of mutual aid. One of the most important systems is known as Gergar, a form of social insurance in which families who lose livestock receive animals from relatives and neighbors to help rebuild their herds. “When people used to lose livestock, others would help them,” says Mohamed Abdi, a lifelong pastoralism advocate and director at Jijiga University’s Institute of Pastoral and Agro-Pastoral Development Studies. “We would move to relatives or sub clan areas, and they shared water and pasture with us.” https://news.mongabay.com/2026/04/sharing-is-off-the-table-as-drought-reshapes-the-lives-of-ethiopias-pastoralists/

Addis Standard

@addisstandardeng · Post #21345 · 09.02.2026 г., 06:51

'Our children are next' fear #Kenyans as #drought wipes out livestock In drought-hit northeastern Kenya, villagers have been forced to drag their dead livestock to distant fields for burning to keep the stench of death and scavenging hyenas away from their homes. Mandera county along Kenya's borders with Ethiopia and Somalia has seen no rain since May and is now on the point of a full-blown water emergency. "I have lost all my cows and goats, and burned them here," Bishar Maalim Mohammed, 60, a resident of Tawakal village, told AFP. In his village, where most are pastoralists relying heavily on their animals, the only remaining bull can no longer stand. He has lain in the same spot for nearly a week, severely dehydrated with bones protruding through his skin, as his owner watches helplessly. https://addisstandard.com/?p=55089

Interesting Planet 🌍

@interesting_planet_facts · Post #492 · 03.08.2025 г., 16:22

🌎 The Madagascan baobab, sometimes called the “upside-down tree,” stores thousands of liters of water in its massive trunk, allowing survival through severe drought. This clever reservoir keeps it lush while nearby plants wilt. ✨ #Madagascar⚡#baobab⚡#drought 👉subscribe Interesting Planet

Reuters: World

@reutersworldchannel · Post #149409 · 15.10.2021 г., 14:23

Northern Kenya drought pushes millions to hunger The lack of rain in northern Kenya means 2.4 million people in the region will struggle to find enough to eat by November, the United Nations World Food Programme says. #News#Reuters#Kenya#drought#food#environment Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Reuters: World

@reutersworldchannel · Post #149225 · 11.10.2021 г., 17:07

U.N. warns of Madagascar 'climate change famine' Madagascar produces less than 0.01% of global carbon dioxide emissions, but amid a fourth year of drought in the Grand Sud region, the U.N. is warning of a 'climate change famine'. #Madagascar#UN#UnitedNations#ClimateChange#ClimateChangeFamine#GrandSudRegion#Drought#News#Reuters Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖