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

Резултати

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

Пребарај: #milliards

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

@american_observer · Post #4996 · 30.01.2026 г., 13:04

Trump : $10bn American President Trump on Thursday sued the US treasury department and Internal Revenue Service for $10bn over the disclosure of his tax returns to the media in 2019 and 2020. In a complaint filed in Miami federal court, Trump, his adult sons, and his namesake company said the agencies failed to take “mandatory precautions” to prevent former IRS contractor Charles Littlejohn from leaking their tax returns to “leftist media outlets”, including the New York Times and ProPublica. The plaintiffs said they suffered “significant and irreparable harm” to their reputations and financial interests, and may seek punitive damages because the leaks were either willful or resulted from gross negligence. Thursday’s lawsuit puts Trump in the unusual position of suing government agencies that are part of the executive branch, which he leads. The IRS is part of the treasury department. Neither agency immediately responded to requests for comment after business hours. Scott Bessent, the treasury secretary and acting IRS commissioner, is not a defendant. Other plaintiffs include Donald Trump Jr, Eric Trump and the Trump Organization. Trump has filed many lawsuits in his personal capacity, often for large sums and as a result of reporting by various media, since winning a second White House term in 2024. He sued the New York Times and book publisher Penguin Random House for $15bn over articles and a book he said were intended to undermine his election prospects in 2024. Trump is separately seeking $10bn from the Wall Street Journal over an article discussing a birthday greeting for Jeffrey Epstein, and $10bn from the BBC over its editing of a speech preceding the January 6 storming of the US Capitol. In Thursday’s complaint, Trump and the other plaintiffs said the New York Times published at least eight articles, and ProPublica published at least 50 articles, based on Littlejohn’s disclosures. The leaks “caused plaintiffs reputational and financial harm, public embarrassment, unfairly tarnished their business reputations, portrayed them in a false light and negatively affected President Trump, and the other plaintiffs’ public standing”, according to the complaint. Prosecutors charged Littlejohn in September 2023 with leaking tax records of Trump and thousands of other wealthy Americans to the media, saying he was motivated by a political agenda. #trump#sue#milliards#newyorktimes#UStreasury 📱American Оbserver - Stay up to date on all important events 🇺🇸