Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках.
Выглядело это примерно так:
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
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
🇺🇸
A French Woman gets paid for doing nothing for 20 years, now she sues ⚖️
Sometimes real life seems stranger than fiction, and this particular incident seems so! At a time when the need for work-life balance ⚖️, and most employees feeling burnt out 😓 has become a matter of great discussion, news is that a woman has now sued her company for paying her to do nothing! 💸
What might sound like a dream situation for many—getting paid without doing any work 😴—has turned into a nightmare for 59-year-old woman named Laurence Van Wassenhove.
She is taking Orange, one of Europe’s largest telecom companies 📞, to court, claiming that the company left her in professional limbo for more than 20 years—by giving her full salary, but no tasks, no responsibilities, and almost no human interaction 😔.
Speaking to French broadcaster FTV 📺, Van Wassenhove described her situation as “forced inactivity” that made her feel invisible at work 👻.
From being a valued employee to being isolated at work
Van Wassenhove joined Orange in 1993, when it was still France Télécom. After developing epilepsy and hemiplegia—partial paralysis on one side of her body 🩺—she moved from her original role to a secretarial position, drawing on her HR background.
But in 2002, everything stalled. Hoping to transfer to another region 📍, she was declared unfit for the proposed role by an occupational health review.
Instead of finding her an alternative, the company placed her on “standby.” This was the start of a 20-year period of professional exile 😞.
“I was paid, yes but treated like I didn’t exist.”
Despite receiving her salary 💰, Van Wassenhove told Mediapart she faced financial difficulties, eviction threats 🏠, and severe mental health struggles while raising her autistic child 👶. The lack of purpose and social connection drove her into deep depression, she said 😢.
Her lawyer, David Nabet-Martin, argues that Orange’s inaction robbed her of “having a place in society” as a disabled person, inflicting lasting psychological harm 🧠.
How her employer responded
Orange told La Dépêche it had taken her “personal social situation” into account and offered the “best possible conditions” during her absence from active work. The company says it explored ways to reintegrate her, but frequent sick leave prevented progress 🚫.
Van Wassenhove began formally raising the issue in 2015 with the government and the High Authority for the Fight Against Discrimination ✊. She claims little changed, and eventually early retirement was suggested—something she saw as yet another push out of the workforce 👋.
Her case highlights the darker side of prolonged inactivity, challenging the assumption that doing nothing for pay is a luxury 🌟.
As she takes her fight to court ⚖️, it could ignite new debates about disability rights, workplace inclusion, and the real meaning of “having a job” 💼.
#wassenhove#paid#nothing#sue#Orange
👂More on Trump's Ear ⚠️