Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках.
Выглядело это примерно так:
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
Аромат дня - Guess 1981 Los Angeles (женский) 💖
Свежими, бодрящими цитрусовыми аккордами мандарина и вкусными фруктовыми нотками душистой груши и ярких ягод красной смородины открывается аромат, сплетаясь в «сердце» композиции с роскошными цветочными оттенками медового пиона, изысканного белого жасмина и чарующим апельсиновым цветом ✨
Восточные ноты нежной пудровой ванили, сладкого пралине, чувственного мускуса и элегантные древесные оттенки сливочно-хвойного кедра завершают великолепный женский парфюм Guess 1981 Los Angeles Woman.
СТОИМОСТЬ💵
Guess 1981 Los Angeles, 100 мл – 2 850 руб
#ЖенскиеАроматы
#Guess
⚫️ Больше ароматов Guess и других брендов по запросу
⚫️ Для заказа и по всем вопросам - @originalproduct_new
🎙 INVEST REPORT ANNOUNCE GUESSIT
⚖️ INVEST REPORT project rating 8/10 ⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️
GUESSIT is an exciting, community-driven game where players buy credits to guess a numeric code. The goal? Crack the safe and win the ever-growing prize pool! Every attempt grows the pot and raises the stakes. But there’s more: an interactive AI Agent guards the safe, securely generates the code, and helps players strategize without revealing the solution. This isn't just a game—it’s a social phenomenon where players come together to share tips, analyze guesses, and compete for glory.
One of the better launches I've seen under these market conditions. Over $2m in volume already.
Project sit now at 8M MC floor and team is waiting when to launch marketing.
Whats more to come?
- Game about to be dropped
- Marketing is about to kick in
- Game viral marketing through TIKTOK
- 2.5X Leverage trading
👉CA: 9PHyv24rtL8RKSnsniZ3G5WwKrChCiDAuMvW3earGr9g
☑️ Follow GUESSIT:
Website: https://guessitsol.ai/
X: https://x.com/guessitonsol
Telegram: https://guessitsol.ai/
TIKTOK: https://www.tiktok.com/@guessitsol
#GUESS#AI#Game
I guessed this word in 3/6 tries.
✏️GRUFF
📅 29.03.2026
🟩🟩⬜️🟧⬜️
⬜️🟩🟧⬜️⬜️
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
Reward: 160 🌟
Can you guess this word❓
PLAY NOW 🔜@DailyPuzzles
#wordle#DailyPuzzles#daily#guess
I guessed this word in 4/6 tries.
✏️ABUSE
📅 27.03.2026
⬜️⬜️⬜️🟧⬜️
⬜️⬜️🟧⬜️⬜️
⬜️🟩🟩⬜️⬜️
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
Reward: 120 🌟
Can you guess this word❓
PLAY NOW 🔜@DailyPuzzles
#wordle#DailyPuzzles#daily#guess
I guessed this word in 5/6 tries.
✏️DALLY
📅 24.03.2026
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
⬜️🟧🟧⬜️⬜️
🟧🟩⬜️⬜️⬜️
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
Reward: 100 🌟
Can you guess this word❓
PLAY NOW 🔜@DailyPuzzles
#wordle#DailyPuzzles#daily#guess
I guessed this word in 6/6 tries
✏️SLINK
📅 20.03.2026
⬜️⬜️⬜️⬜️🟧
⬜️⬜️⬜️⬜️⬜️
🟧⬜️⬜️⬜️🟧
🟩🟩🟧🟧⬜️
🟩🟩🟩🟩⬜️
🟩🟩🟩🟩🟩
Reward: 100 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess
I guessed this word in 3/6 tries
✏️ENEMY
📅 17.03.2026
🟩⬜️🟩⬜️⬜️
⬜️🟧⬜️⬜️🟧
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
Reward: 160 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess
I guessed this word in 5/6 tries
✏️CACHE
📅 16.03.2026
⬜️⬜️⬜️🟩⬜️
⬜️⬜️⬜️🟩⬜️
🟩⬜️⬜️🟩⬜️
🟩⬜️⬜️⬜️🟧
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
Reward: 120 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess
I guessed this word in 5/6 tries
✏️LABEL
📅 14.03.2026
⬜️⬜️⬜️🟩⬜️
⬜️⬜️⬜️🟩⬜️
🟩⬜️⬜️🟩⬜️
🟩⬜️⬜️⬜️🟧
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
Reward: 120 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess
I guessed this word in 5/6 tries
✏️SILLY
📅 13.03.2026
⬜️⬜️🟩🟩🟩
⬜️⬜️🟩🟩🟩
⬜️🟩🟩🟩🟩
⬜️🟩🟩🟩🟩
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
Reward: 120 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess
I guessed this word in 6/6 tries
✏️CAMEL
📅 12.03.2026
⬜️⬜️⬜️🟩⬜️
⬜️⬜️⬜️🟩⬜️
⬜️⬜️⬜️🟩⬜️
⬜️⬜️⬜️🟩⬜️
🟩⬜️⬜️🟩⬜️
🟩🟩🟩🟩🟩
Reward: 100 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess