Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках.
Выглядело это примерно так:
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
🔠🅰️🔠🔠2️⃣
The lack of consistent regulation elsewhere creates unacceptable risks, and addressing those risks to protect young boys should be an urgent priority.”
Prof Faye Ruddock, chair of the Caribbean and African Health Network said the lack of official information on the issue could fuel risks.
“We need measures to ensure people are educated on the risks when they have their baby, but currently this information isn’t readily available in perinatal and neonatal spaces, or community spaces like churches,” Ruddock said.
“Safeguarding and culturally competent regulation is something that would go a long way. Nobody wants their child to die, but not everyone has the same access to people who are credible.”
Last January, a private circumciser and former doctor, Mohammad Siddiqui, was sentenced to more than five years in prison for causing “gratuitous pain and suffering” to children in “unsanitary and dangerous” circumcisions.
In May, Mohammed Alazawi, who falsely claimed to be a doctor, was convicted of six counts of wounding with intent in circumcision procedures. The judge said the law around male circumcision should be changed because it “remains almost entirely unregulated”.
Gordon Muir, a London-based consultant urological and andrological surgeon, argued that the procedure is “unnecessary and will not do any physical good”.
“I think it is a form child abuse and the correct thing to do would be to wait until the child is 16 or more and is able to make a rational decision about it,” he said.
Muir said he has faced hundreds of letters of criticism when he published an academic paper that found there was no high-quality evidence to support any benefits from circumcision, and that in rare instances it caused avoidable harm and occasional deaths.
Rabbi Jonathan Romain, the convener of Reform Beit Din, Progressive Judaism’s religious court, defended circumcision as an “enormously powerful symbolic act of identity”.
He said Progressive Judaism, which represents 83 congregations, was developing a training, mentoring and monitoring scheme to ensure a “new generation of circumcisers” was educated in best practice, urging the government to adopt a model that “covers all faiths and traditions” and carried legal penalties for anyone who operated outside it.
The National Secular Society welcomed the CPS guidelines. But its human rights lead, Alejandro Sanchez, a former NHS doctor, said:
“Relying on the criminal justice system only deals with harm after it has happened. The priority now must be to prevent that harm from occurring in the first place.”
“Circumcision, as a surgery, is inherently dangerous. It should only be performed by doctors and, when it comes to children, only with medical necessity.
“Decisions about circumcision should therefore be deferred until the individual is old enough to decide for himself, based on his own values.”
#circumcision#child#abuse#judaism
📱American Оbserver - Stay up to date on all important events
🇺🇸
Don’t Cut Babies’ Foreskin !
🔠🅰️🔠🔠1️⃣
Circumcision is to be classed as a potential form of child abuse under new guidance for prosecutors, amid concerns from judges and coroners about deaths and serious harms caused by the procedure.
A draft document by the Crown Prosecution Service (CPS) on “honour-based abuse, forced marriages, and harmful practices”, classes circumcision as a potential crime alongside breast flattening, virginity testing, hymenoplasty and exorcisms.
The wording of the document, seen by the Guardian, has alarmed some religious groups, with Jewish and Muslim leaders defending the cultural importance of the practice.
The draft CPS guidance states that, unlike female genital mutilation, “there is not a specific criminal offence of carrying out male circumcision”.
“However, this can be a painful and harmful practice, if carried out incorrectly or in inappropriate circumstances.
It may be a form of child abuse or an offence against the person,” it adds.
Last month, a coroner issued warnings about insufficient regulation over who can perform a circumcision after the death of a six-month-old boy, Mohamed Abdisamad, from a streptococcus infection in 2023.
The wording of the document, seen by the Guardian, has alarmed some religious groups, with Jewish and Muslim leaders defending the cultural importance of the practice.
The draft CPS guidance states that, unlike female genital mutilation, “there is not a specific criminal offence of carrying out male circumcision”.
“However, this can be a painful and harmful practice, if carried out incorrectly or in inappropriate circumstances. It may be a form of child abuse or an offence against the person,” it adds.
Last month, a coroner issued warnings about insufficient regulation over who can perform a circumcision after the death of a six-month-old boy, Mohamed Abdisamad, from a streptococcus infection in 2023.
The case echoed another coroner’s concerns over the death of Oliver Asante-Yeboah who died in 2014 from sepsis after a circumcision was performed on him by a rabbi.
According to the Office for National Statistics, since 2001 there have been seven deaths of boys under 18 where circumcision was a factor.
At least three of these involved babies who bled to death: Celian Noumbiwe in 2007; Goodluck Caubergs in 2010; and Angelo Ofori-Mintah in 2012.
Jonathan Arkush, a former president of the Board of Deputies of British Jews and co-chair of Milah UK, which promotes and protects the right of the Jewish community to carry out religious circumcision, said the wording in the draft CPS guidance was misleading.
“To suggest that circumcision is in itself a harmful practice, is deeply pejorative and misplaced,” he said.
“Any procedure that is carried out inappropriately or without proper controls, including piercing a child’s ears, could be a harmful practice and a possible case of child abuse.”
He added: “We shall certainly be talking to the CPS. I would very much expect that final draft not to include it, as it is so obviously incorrect and/or misleading.”
Arkush, who is also a barrister, accepted that if performed incorrectly, circumcision could constitute abuse, but he insisted the “stringent standards” applied by the Jewish community ensured this did not happen.
“The incidence of complications in circumcision performed in the Jewish community is vanishingly rare,” he said.“Circumcision is a core part of our identity.
I have never met any Jewish man who thinks they’ve been harmed by circumcision.”
#circumcision#child#abuse#judaism
📱American Оbserver - Stay up to date on all important events
🇺🇸
Khamenei’s Hangmen Sexually Abused a Teen Protester
A 16-year-old was among protesters sexually assaulted in custody by the security forces in Iran during the nationwide uprising that has left thousands dead, according to a human rights group.
Two people, one of them a child, detained in the city of Kermanshah in western Iran told the Kurdistan Human Rights Network (KHRN) that they were subjected to sexual abuse by riot police during their arrest.
“During the transfer, security forces touched their bodies with batons. They beat and applied pressure to the anal area with a baton through the clothing,” said Rebin Rahmani, of the KHRN, which has been in contact with sources close to the minor’s family.
Rights groups have expressed fear about the treatment of more than 20,000 protesters estimated to have been arrested since the start of protests in late December.
Since the start of the current protests in late December, 3,766 people have been killed and 8,949 other reported deaths are under investigation, according to the US-based Human Rights Activists News Agency.
The Norway-based Kurdish human rights group Hengaw said Sholeh Sotoudeh, a pregnant woman from Langarud, was killed along with her unborn child after forces opened fire on protesters in north-west Iran on 10 January.
In the latest unrest, at least one protester, 40-year-old Soran Feyzizadeh, has died as a result of torture while being held in custody, according to Hengaw.
It said Feyzizadeh was detained during protests on 7 January and that his family was informed of his death two days later.
The US-based Abdorrahman Boroumand Center for Human Rights in Iran has documented the cases of more than 549 protesters, including 51 women, who have been transferred to Yazd central prison, and it expressed extreme concern over the lives of detainees.
“As street protests wind down, arbitrary arrests have increased as has the risk of torture for detainees,” said Roya Boroumand, the centre’s executive director.
“Over the past decades we have documented numerous cases of death in custody alongside severe physical and psychological torture, including beating, flogging and sexual assault.”
#iran#protesters#sexual#assault#abuse
📱American Оbserver - Stay up to date on all important events
🇺🇸
Three Israeli women released by Hamas left #Gaza with smiles, gift bags, and health intact, while Palestinians, many held in Israeli prisons without charge, endured #torture, #trauma, and #abuse.
#Israel#Palestine
Willowbrook State School was a large institution in Staten Island, New York. It cared for children and adults with intellectual disabilities. The school became overcrowded and understaffed. Conditions were dirty and unsafe. People got sick from diseases like hepatitis. Researchers gave some residents hepatitis on purpose to study it. In 1972, journalist Geraldo Rivera showed the poor conditions on TV. Senator Robert F. Kennedy called it a "snake pit." Lawsuits forced the school to make changes. Willowbrook closed in 1987. Parts of the campus are now used by the College of Staten Island.
🏫⚠️🧪📺
Be advised, this is not fun to watch, but it's recent history these people are still alive.
[Watch for yourself]
[Read more]
@googlefactss
#Willowbrook#History#DisabilityRights#StatenIsland#USA#humanExperiments#abuse