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

Резултати

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

Пребарај: #american

当前筛选 #american清除筛选
BadVolf

@BadvolfNews · Post #664 · 14.06.2023 г., 20:20

Want more information on Michael Travis Leake, the #American "Rock musician" arrested in #Moscow? Well, I have some for you. For instance, he wasn't an Army paratrooper, like you're being told. You can thank me later!

Journey to Fluency

@fluencyinenglish · Post #6325 · 11.08.2018 г., 16:57

#collocations #british #american @ieltsstrategies 🔴British English vs American 🔸go on holiday~ British English 🔹take a vacation ~ American English 🔸get a driving licence~ Brit 🔹get a driver's licenc~ Ame 🔸 visit a city centre~ Brit English 🔹go downtown~ Ame English 🔸have a bath~ Brit English 🔹 take a bath~ Ame English @ieltsstrategies

Лёгкое небо

@legkoenebo · Post #4064 · 02.07.2025 г., 08:17

Хакеры атакуют авиакомпании Северной Америки 🌎 Киберпреступная группа Scattered Spider, известная взломами корпоративных ИТ-систем с последующим вымогательством, нацелилась на авиационный сектор Северной Америки. По имеющейся информации, хакерам удалось получить доступ к системам двух крупных авиаперевозчиков — канадской WestJet и американской Hawaiian Airlines. К счастью, ни одна из компаний не зафиксировала сбоев в работе. Эта активность вновь подняла вопрос о киберугрозах в авиации и побудила специалистов по информационной безопасности усилить защиту корпоративных данных. 📌На фоне этих событий American Airlines сообщила о проблеме в собственной ИТ-инфраструктуре, которая привела к задержкам рейсов по всей сети. Лёгкое небо #aviation#American#Hawaiian#WestJet

American Оbserver

@american_observer · Post #5220 · 25.02.2026 г., 13:04

Is Trump Racking Up Victories For the American People or For Himself? 🤔🇺🇸 Trump proclaimed his first year in office a success at the State of the Union address on Tuesday evening, even as his presidency is dogged by low public approval ratings before November’s midterm elections in which voters could hand control of Congress back to his Democratic opponents. The annual address to a joint session of Congress came after months of turmoil for the Republican president, including a crackdown on immigrant communities in Minneapolis that resulted in the deaths of two US citizens, and faltering progress on his campaign promise of lowering the cost of living. Despite Democrats walking out, holding signs, and verbally clashing in the chamber, Trump maintained a triumphant tone in his speech, arguing that he had rebuilt a country ruined by Biden. Speaking for just under two hours, his speech was the longest State of the Union ever delivered, and saw Trump repeatedly bring out surprise guests to serve as living embodiments of what he saw as the country’s greatness. “We will never go back to where we were just a very short time ago. We’re not going back.” Recent surveys have shown that many voters disagree. A Washington Post-ABC News-Ipsos poll released this week found a mere 39% of voters view his presidency positively, and others have found him underwater on key issues such as the economy and immigration. But Trump gave no acknowledgment to the bad vibes, instead running through his administration’s accomplishments in a speech that was interspersed with falsehoods and exaggerations but light on new policy proposals. He announced that his vice-president, Vance, would lead a “war on fraud”, and that he had negotiated a “ratepayer protection pledge” to offset the impact of new data centers on households electricity costs. Four supreme court justices were in attendance, three of whom – John Roberts, Amy Coney Barrett and Elena Kagan – had last week signed on to an opinion saying he could not use executive power to impose tariffs on US trading partners. As the three sat in the front row together with Brett Kavanaugh, who had not signed on to their opinion, Trump issued a relatively measured criticism of their decision, calling it “unfortunate” and “disappointing”. He was less restrained when it came to Democratic lawmakers, who he wrote off as “crazy”, or Somali immigrants, who he described as “pirates who ransacked Minnesota”, the site of a long-running and contentious immigration operations. And though he has ordered a major military buildup around Iran, he revealed little about what his intentions were for the longtime US adversary. “My preference is to solve this problem through diplomacy. But one thing is certain, I will never allow the world’s number one sponsor of terror, which they are by far, to have a nuclear weapon,” Trump said. Reviews from those who remained throughout were equally negative. “For nearly two hours tonight, Trump spewed lies, propaganda and hatred,” said Hakeem Jeffries, the top House Democrat in a statement. “Instead of presenting the nation with a positive vision for our future and the economy, the president blamed others for his failures.” The speech was nonetheless a key moment ahead of the November midterm elections, in which Trump’s Republican allies are defending their slim control of the Senate and House. After failing to stop Trump’s return to the White House in 2024, Democrats have taken heart from successes in recent off-year and special elections that may indicate voters are ready to deliver them victories in key races that could decide control of Congress. The official response to Trump’s speech was delivered by Abigail Spanberger, the Virginia governor who won a decisive victory last year in an election that put Democrats firmly in control of the southern state. #trump#trump#victories#american#people#democrats 📱American Оbserver - Stay up to date on all important events 🇺🇸

Addis Standard

@addisstandardeng · Post #21300 · 04.02.2026 г., 06:58

News: #Egypt-based military drones have targeted #Sudan’s RSF for months, report says A covert military airstrip in Egypt’s Western Desert has emerged as a key launch site for drone strikes inside Sudan, signaling Egypt’s direct entry into Sudan’s devastating civil war, according to an extensive investigation by The New York Times. The report, based on satellite imagery, flight records, video analysis, and interviews with #American, #European, and #Arab officials, found that advanced military drones operating from Egypt have been conducting strikes against Sudan’s Rapid Support Forces (#RSF) for at least 6 months. The airstrip, located near the East Oweinat agricultural project close to the Sudanese border, is hidden amid vast wheat fields irrigated by fossil aquifers. While the base appears civilian on the surface, satellite images reviewed by the newspaper show the construction of a second runway, at least 17 aircraft hangars, satellite communications.... Read more: https://addisstandard.com/?p=54976

12
ПретходнаСтраница 1 од 2Следна