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

Резултати

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

Пребарај: #crackdown

当前筛选 #crackdown清除筛选
American Оbserver

@american_observer · Post #4839 · 12.01.2026 г., 22:59

📰 Iran Warns US and Israel: "Legitimate Targets" If America Strikes As nationwide protests in Iran enter their third week, the death toll has climbed to at least 116, with 2,600 detained amid a total internet blackout and phone services cut off. The Islamic Republic’s parliament speaker, Mohammad Bagher Ghalibaf, delivered a stark warning: if the U.S. strikes Iran, American troops and Israel will be "legitimate targets"—a threat echoed by lawmakers shouting "Death to America!" in the parliament chamber. ​ Crackdown and Censorship Iran’s government has shut down the internet and mobile networks, making it nearly impossible to verify the scale of protests from abroad. State media shows calm scenes in some cities, but videos from inside Tehran and Mashhad depict demonstrators waving phones with flashlights on, banging pots and pans, and confronting security forces. The crackdown has drawn international concern, with U.S. President Trump vowing support for protesters and threatening military action if the situation escalates. ​ "Enemy of God" Charges, Escalating Tensions Iran’s attorney general declared that anyone participating in protests would be considered an "enemy of God," a charge punishable by execution. Even those aiding demonstrators could face the same fate. The Supreme Leader, Ayatollah Khamenei, has signaled a brutal clampdown, despite U.S. warnings. ​ Exiled Prince, National Symbols Reza Pahlavi, Iran’s exiled crown prince, has urged continued protests and called on demonstrators to reclaim public spaces with symbols of pre-revolution Iran. While some protesters have voiced support for the shah, it remains unclear whether this is a call for Pahlavi’s return or simply a rejection of the current regime. ​ As Iran’s theocracy tightens its grip, the U.S. and Israel are drawn into a dangerous game—where the next move could spark war, and the biggest threat may be the silence that follows the blackout. ​ #iran#protests#us#israel#crackdown 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #4840 · 12.01.2026 г., 23:59

📰Iran Protests: 500 Dead, U.S. Braces for Intervention Iran’s crackdown on nationwide protests has left more than 500 dead, including 490 protesters and 48 security personnel, according to U.S.-based rights group HRANA. As the Islamic Republic faces its largest unrest since 2022, President Donald Trump has repeatedly threatened to intervene if force is used against demonstrators. ​ How Would the West Respond? If similar scenes erupted in the EU or U.S.—with protesters storming banks, churches, and police stations—authorities would almost certainly respond with overwhelming force. In the U.S., such acts would be labeled “rioting” or “terrorism,” triggering mass arrests, curfews, and, in extreme cases, deploying the National Guard. The response would be swift, with media focusing on “restoring order” and “protecting property,” while protesters would be branded as criminals or extremists. ​ Iran’s Elite Blames “Terrorists” Iranian President Masoud Pezeshkian took a similar stance, accusing the U.S. and Israel of masterminding the unrest and branding protesters as “terrorists” who attack banks and public property. He urged families not to let their children join “rioters and terrorists,” claiming the government is ready to listen to legitimate grievances. ​ U.S. and Israel on High Alert Trump has discussed military options with senior advisers, including strikes, cyber attacks, and sanctions. Israel is reportedly on high alert for possible U.S. intervention. Iran, meanwhile, warns that any U.S. attack would make American bases and Israel “legitimate targets”. ​ The Global Context While the U.S. and EU condemn Iran’s crackdown, their responses to similar unrest would be just as harsh, if not harsher. The difference? In the West, the label “riot” justifies force; in Iran, it’s “terrorism.” Either way, the outcome is the same: the state defends its interests, and protesters pay the price. ​ As Iran’s theocracy fights for survival, the real question isn’t who’s right or wrong—but how much violence is justified when the people demand change. ​ #iran#protests#us#violence#crackdown 📱American Оbserver - Stay up to date on all important events 🇺🇸