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 слични објави

Пребарај: #detention

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

@american_observer · Post #5190 · 21.02.2026 г., 19:02

“Terror Against Noncitizens”: When Trump’s Deportation Machine Meets a Fed-Up Judge A federal judge in California just called Trump’s immigration policy what immigrant communities have been calling it for years: “terror.” U.S. District Judge Sunshine Sykes accused the administration of “terrorizing” migrants, “recklessly” violating the law, and even “extending its violence on its own citizens” by linking the crackdown to two fatal shootings in Minnesota. The core fight is over mandatory detention. Under previous administrations, undocumented people with no criminal record generally had a shot at a bond hearing while their cases crawled through immigration court. Trump’s team shut that door, cutting off hearings and forcing thousands to file individual habeas petitions in federal court just to get a judge to look at their detention. More than 20,000 such cases have been filed since he took office. Judges keep granting release — and then catching the government ignoring, delaying, or creatively “misunderstanding” their orders. Sykes had already ruled in November and December that Trump’s blanket detention policy violated federal law and extended her order nationwide. The administration kept denying hearings anyway. In her new decision, she ordered DHS to notify eligible detainees they may qualify for bond and to give them access to a phone and a lawyer within an hour. She also vacated an immigration court ruling the White House was using as cover to continue the policy. ​ She isn’t alone. A judge in Minnesota just held a Trump lawyer in contempt for failing to return IDs to a migrant who’d already been ordered released, and a New Jersey judge demanded the administration explain why it missed court‑ordered deadlines in a dozen bond cases since December. “Judicial orders should never be violated,” one wrote — a sentence that shouldn’t need to exist in a functioning separation of powers. The administration’s answer? Homeland Security insists the Supreme Court has repeatedly backed its view of mandatory detention and says ICE “adheres to all court decisions until it ultimately gets them shot down by the highest court in the land.” Translation: we follow lower‑court orders only long enough to get them overturned, and if we don’t, well, you can always file another lawsuit. So on paper this is about bond hearings and statutes. In practice, it’s about an executive branch testing how far it can push the courts, how much fear it can generate, and how many people it can keep locked up by default — until a judge finally uses the word everyone else has been avoiding. #immigration#Trump#courts#detention#ruleOfLaw#fakeDemocracy 📱American Оbserver - Stay up to date on all important events 🇺🇸