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

Резултати

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

Пребарај: #sunni

当前筛选 #sunni清除筛选

伊斯蘭恐懼症 在西方單邊主義宣傳侵佔一定空間的國際大媒界, 伊斯蘭恐佈症在西方社會及親西方群體宣傳得非常成功, 不多不少也是遜尼派人口之中的極右派(Wahabism) ,接近(原教旨主義) Wahabism 思想及遜尼派社會一些人不良行為而被宣傳加工所導致。 #ABC #Sunni #Islam #Muslim

Graduates of #Deoband and #Wahhabi schools killed 12 people last night. In the terrorist attack on a police station in the Sistan region of Iran, 12 people were martyred and many were injured. The headquarters of the Jaish-ul-Adl terrorist group is in #Pakistan. They have been taught to be kind to infidels, but if you kill 5 Muslims, you will go to heaven. The funds of these groups are provided by America and Israel. Pakistan is a breeding ground for #Sunni terrorists. https://t.me/YediotNewsChat

The picture of the dead body of one of the #Sunni terrorists who invaded Iran's border post last night. They were wearing the uniform of the Iranian military forces. The rest of the #Wahhabi terrorists fled to Pakistan. They hide in the deserts of Pakistan for the next surprise attack on Muslims. Pakistan is the center of production of Wahhabi terrorists. The Wahhabis came to power in #Saudi_Arabia in 1922 by the #British. https://t.me/YediotNewsChat

Today, the funeral ceremony of 280 unknown martyrs was held in some cities of Iran with the presence of the president. The bodies of these martyrs have recently been discovered from under the ground in war zones. Despite the "DNA" test, some of the martyrs are still unknown. Because they don't know where their families are. In 1980, Iraq attacked Iran at the instigation of the #United_States with the cooperation of all #Sunni Arab countries to overthrow the Iranian Shiite government, but they did not achieve their goal. This war imposed on Iran was carried out with the participation of 80 countries and ended in 1988 with one million dead and wounded. Today, there is neither Saddam Hussein nor the terrorist #Baath Party of Iraq. But the more powerful Islamic Republic is fighting the Israeli terrorists in #Jerusalem since 1988. https://t.me/YediotNewsChat

Moscow Photographer

@moscowphotog · Post #1489 · 08.03.2025 г., 13:48

"A new massacre against the #Alawites in the city of #Latakia, in the #Dattour neighborhood, al-Mazar junction. I beg all segments of the Syrian people, especially the #Druze, #Kurds, and any remaining members of the #Sunni community who still have a little humanity left in their hearts, to take to the streets in protest to stop these massacres against the innocent. These #massacres are not from yesterday, they are happening today, and as of moments ago, they are still being carried out by Syrian members of Hay’at Tahrir al-Sham #HTS, wearing their official uniforms. Please, save those who remain." https://t.me/CoastSyrian24/771