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

Резултати

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

Пребарај: #riddle

当前筛选 #riddle清除筛选
Language Trivia 🤔

@languagetrivia · Post #536 · 24.12.2024 г., 06:00

🦫 Riddle: This 🇬🇧 British beaver is holding a mystery vegetable. What would he say he is holding? Options: A) Zucchini B) Courgette C) Cucumber D) Turnip E) Aubergine Press the button below to see the right answer. Did you guess it right? Yes 😎 | No 🌚 @languagetrivia#riddle

Hashtags

Language Trivia 🤔

@languagetrivia · Post #245 · 28.10.2024 г., 19:11

🧩 Riddle I’m a language spoken in a country known for its temples and street food. Written with a beautiful, looping script with no spaces between words. I use five tones to change the meaning of a word. What language am I? #guess_the_language#riddle 🦫@languagetrivia

Ask Me

@askmenow · Post #2871 · 07.03.2021 г., 11:59

1. One Light Year is equal to? Ans . the distance traveled by light in one year 2. Liquefied petroleum gas (LPG) is mainly a mixture of ___? Ans . propane and butane 3. The Ozone layer lies in the which layer? Ans . Stratosphere 4. Most of the light rays inside a tubelight is in the form of____? Ans . ultra -violet light 5. Which is the alkalodid that contains in cola drinks? Ans . Caffeine 6. The device used for detecting even feeble current: Ans . Galvanoscope Via @askmenow ------------------------------ #Idiom "When pigs fly" What it means?Check Answer #Riddle What has a thumb and four fingers, but is not a hand" What is it?Check Answer ------------------------------- For Fun: Be Like Bro & sarcasticLOL Today's Quiz MCQ:Quiz MCQ

Ask Me

@askmenow · Post #2858 · 12.02.2021 г., 17:47

Daily Questions and Answers 1. ‘Mechanical Clock’ made by whom? Ans . Isaac Newton 2. By which Cotton fibers are made? Ans . Cellulose 3. What is the name of the tube which connects the middle ear with the throat? Ans . Eustachian tube Via @askmenow #Idiom " A slap on wrist " What it means?Check Answer #Riddle "I’m tall when I’m young, and I’m short when I’m old" What am I?Check Answer

Ask Me

@askmenow · Post #2857 · 11.02.2021 г., 06:59

1. What is the speed of Earth around sun? Ans . 30 km/sec 2. In our solar system the MARS is fourth planet according to sequences but how many moons has ‘Planet MARS’? Ans . 2 3. To measure the Humidity in air, what instrument used? Ans . Hygrograph 4. Splitting of light into its constituent colors is known as what? Ans . Dispersion 5. Basically the heavy water is used by which type of industries? Ans . Nuclear Power Generation plants Via @askmenow #Riddle "What belongs to you but is used most by other people" What is it?Check Answer #Idiom "The ball is in your court" What it means?Check Answer For fun: SarcasticLOL & Be Like Bro Today's news headline: read here

Ask Me

@askmenow · Post #2854 · 08.02.2021 г., 18:23

Daily Questions and Answers 1. Where is Hagia Sophia located? Answer: Istanbul, Turkey 2. Which region can be called the belt of Doldrums? Answer: Equatorial region 3. What is the study of landforms called? Answer: Geomorphology Via @askmenow #Idiom "Blood is thicker than water" What it means?Check Answer #Riddle "What's so fragile that it breaks when you speak it" What is it?Check Answer Today's News headlines:read here Try: Quiz MCQ For Fun:Be Like Bro , sarcasticLOL

Language Trivia 🤔

@languagetrivia · Post #368 · 22.11.2024 г., 16:31

Why does Burmese (the language spoken in Myanmar, formerly Burma) use rounded characters instead of straight lines? Take the quiz below to find out! @languagetrivia#riddle#image

Anatomy Art Hub ☮️

@anatomyarthub · Post #5043 · 28.04.2025 г., 05:34

#загадка#riddle 6️⃣ Моя спина такая заботливая — она всегда напоминает мне, когда я старею... особенно, когда я просто чихнул. My back is so caring - it always reminds me when I'm getting old... especially when I just sneeze. @anatomyarthub

Anatomy Art Hub ☮️

@anatomyarthub · Post #4182 · 29.12.2024 г., 06:38

#загадка#riddle 5️⃣ Нормальная длина ног - когда ноги достают до пола. Так что это за мышца? Normal leg length is when your legs reach the floor. So what is this muscle? @anatomyarthub

123•••1011
ПретходнаСтраница 1 од 11Следна