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

Резултати

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

Пребарај: #decrease

当前筛选 #decrease清除筛选

⬛️Iqtisodiy faktlar... 🇺🇸AQShdagi Buyuk retsessiya: sabablari, oqibatlari va saboqlari 💵Ushbu iqtisodiy beqarorlik davri 1930-yillardagiBuyuk Depressiyadan keyingi eng jiddiy inqiroz deb hisoblanadi. “Buyuk retsessiya” atamasi 2007-yil dekabridan 2009-yil iyunigacha davom etgan AQSh tanazzuliga ham, 2009-yilda sodir bo‘lgan jahon iqtisodiytanazzulga ham aloqador. 🔎Batafsil 🚩 Великая рецессия в США: причины, последствия и уроки 📊Этот период экономической нестабильности считается самым серьёзным кризисом со времён Великой депрессии 1930-х годов. Термин «Великая рецессия» относится как к рецессии в США, продолжавшейся с декабря 2007 по июнь 2009 года, так и к глобальному экономическому спаду, который последовал в 2009 году. 🔎Подробнее #GraduateSchool#Recession#Decrease#Economy 🔝Web-site |🔝Facebook | 🔝Instagram | 🔝Youtube

📕Iqtisodiy atamalar... 📈 Ushbu davrda kompaniyalar xarajatlarni qisqartirishi, iste’molchilar talabi pasayishi, ishsizlik ortib borishi kuzatiladi, bu esa mamlakatning umumiy iqtisodiy iqlimiga salbiy ta’sir ko‘rsatadi. 🏭 Retsessiya iste’mol xarajatlarining pasayishi, kreditshartlarining yomonlashishi, tashqiiqtisodiy zarbalar yoki investitsiyalarning keskin kamayishi kabi turli omillar tufayli yuzaga kelishi mumkin. 📊 During this time, companies reduce spending, consumer demandfalls, and unemploymentrises, negativelyaffecting the country’s overall economic climate. ⬇️ A recession can be triggered by various factors, such as lower consumer spending, worsening creditconditions, externaleconomic shocks, or a sharp drop in investment. #GraduateSchool#Recession#Decrease#Economy 🔝Web-site |🔝Facebook | 🔝Instagram | 🔝Youtube

Journey to Fluency

@fluencyinenglish · Post #7852 · 05.04.2022 г., 08:31

#common_mistakes #decrease #in#of @fluencyinenglish معمولاً از عبارت زیر برای کاهش در چیزی صحبت می کنیم. ✔️ decrease in sth با این حال،معمولاً از عبارت زیر برای کاهش مقدار بکار می بریم. ✔️ decrease of sth مثال: • There has been a 2% decrease in the rate of unemployment. 2 درصد کاهش در نرخ بیکاری وجود داشته است. • There has been a decrease of 2%. 2 درصد کاهش وجود داشته است. • There was a slight decrease in his weight after a week of dieting. بعد از یک هفته رژیم، یک کاهش کوچک در وزنش وجود داشت. • Any decrease in tourism could have a serious effect on the local economy. هر گونه کاهشی در گردشگری می‌توانست اثری جدی بر اقتصاد محلی بگذارد. • The report's finding on the decrease in violent crime supports the police chief's claims. • We have seen a marked decrease in the number of accidents since these safety measures were introduced. از وقتی این تدابیر امنیتی ارائه شدند، کاهش شدیدی در تعداد تصادفات مشاهده شده است. • We've noticed a steady decrease in jobs available for new graduates in the industry. @fluencyinenglish

Journey to Fluency

@fluencyinenglish · Post #7837 · 18.07.2021 г., 06:26

#common_mistakes #decrease #in#of @fluencyinenglish معمولاً از عبارت زیر برای کاهش در چیزی صحبت می کنیم. ✔️ decrease in sth با این حال،معمولاً از عبارت زیر برای کاهش مقدار بکار می بریم. ✔️ decrease of sth مثال: • There has been a 2% decrease in the rate of unemployment. 2 درصد کاهش در نرخ بیکاری وجود داشته است. • There has been a decrease of 2%. 2 درصد کاهش وجود داشته است. • There was a slight decrease in his weight after a week of dieting. بعد از یک هفته رژیم، یک کاهش کوچک در وزنش وجود داشت. • Any decrease in tourism could have a serious effect on the local economy. هر گونه کاهشی در گردشگری می‌توانست اثری جدی بر اقتصاد محلی بگذارد. • The report's finding on the decrease in violent crime supports the police chief's claims. • We have seen a marked decrease in the number of accidents since these safety measures were introduced. از وقتی این تدابیر امنیتی ارائه شدند، کاهش شدیدی در تعداد تصادفات مشاهده شده است. • We've noticed a steady decrease in jobs available for new graduates in the industry. @fluencyinenglish

Crypto M - Crypto News

@CryptoM · Post #65206 · 12.04.2026 г., 01:42

🚀 Bitcoin(BTC) Drops Below 72,000 USDT with a 1.23% Decrease in 24 Hours On Apr 12, 2026, 01:42 AM(UTC). According to Binance Market Data, Bitcoin has dropped below 72,000 USDT and is now trading at 71,964.390625 USDT, with a narrowed 1.23% decrease in 24 hours. #Bitcoin#BTC#USDT#Binance#cryptocurrency#marketdata#price drop #decrease

Crypto M - Crypto News

@CryptoM · Post #64548 · 09.04.2026 г., 07:21

🚀 Bitcoin(BTC) Drops Below 71,000 USDT with a 1.14% Decrease in 24 Hours On Apr 09, 2026, 07:21 AM(UTC). According to Binance Market Data, Bitcoin has dropped below 71,000 USDT and is now trading at 70,975.132813 USDT, with a narrowed 1.14% decrease in 24 hours. #Bitcoin#BTC#cryptocurrency#USDT#Binance#marketdata#priceupdate#decrease#24hours

Crypto M - Crypto News

@CryptoM · Post #65266 · 12.04.2026 г., 13:01

🚀 Bitcoin(BTC) Drops Below 71,000 USDT with a 2.59% Decrease in 24 Hours On Apr 12, 2026, 13:01 PM(UTC). According to Binance Market Data, Bitcoin has dropped below 71,000 USDT and is now trading at 70,972.90625 USDT, with a narrowed 2.59% decrease in 24 hours. #Bitcoin#BTC#USDT#cryptocurrency#marketupdate#Binance#pricechange#decrease#24hour