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

Резултати

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

Пребарај: #didyouknow

当前筛选 #didyouknow清除筛选
MyGov Newsdesk

@mygovcoronanewsdesk · Post #11421 · 21.11.2022 г., 05:59

#DidYouKnow❓ Relying on the healing power of nature, Naturopathy stimulates the human body's ability to heal itself! Test your knowledge about Naturopathy. Take the quick quiz today! Visit: https://quiz.mygov.in/quiz/naturopathy-quiz/

Hashtags

gov.sg

@Govsg · Post #3013 · 16.05.2025 г., 09:33

📢 The Weekly Wrap – 16 May 2025 1) #DidYouKnow Today is Drug Victims Remembrance Day? An annual observance to rally together on the harms and trauma of drug abuse. Visit the “Museum of Us” exhibition from 16 to 18 May at Suntec City, 10am to 8pm, to get an insider perspective on the impact of drug abuse and offer support in the healing process. 🔗 Show your support at: go.gov.sg/rday2025. 2) The Together, for Better roadshows: Back in your ‘hood! Our roadshows are back, and we’re making our way to Bukit Panjang and Hougang this weekend! What’s in store for you: ✅ Interactive exhibits 💼 Professional advice on jobs and upskilling 🎁 Join quizzes and win prizes 🔗 More details: togetherforbetter.gov.sg/events-and-roadshows/ See you at Hillion Mall and Hougang Mall on 17 & 18 May, from 11am to 8pm!

Hashtags

Ask Me

@askmenow · Post #2848 · 29.01.2021 г., 19:31

Daily Questions and Answers 1. The ‘Roof’ of the world is referred to which place? Answer: Pamir knot 2. What is the currency in Cambodia? Answer: Riel 3. What is dew point? Answer: The temperature at which dew begins to evaporate 4. How do you measure the speed of wind? Answer: Anemometer 5. Name the river that is not crossed by any bridges. Answer: Amazon #DidYouKnow One million Earths could fit inside the sun! Via @askmenow News headlines: read here Try: Quiz MCQ For Fun: Be Like Bro , sarcasticLOL

Hashtags

Ask Me

@askmenow · Post #2846 · 29.01.2021 г., 09:22

1. How many countries are present in Africa? Answer: 54 countries 2. Which planet is closest to Planet Earth? Answer: Venus 3. What erupts from a volcano? Answer: Lava, steam, ash, pieces of rock, and gaseous sulfur compounds 4. What is the name of the strait that separates the north and south islands of New Zealand? Answer: Cook strait 5. Which is the direction at which wind blows? Answer: Leeward direction #DidYouKnow At over 2,000 kilometers long, The Great Barrier Reef is the largest living structure on Earth Via @askmenow Know more about: 1- Venezuela Oil Crisis 2. Rohingya Refugee Crisis News headlines(29.01.2021): read here Try: Quiz MCQ For Fun:Be Like Bro , sarcasticLOL

Hashtags

Ask Me

@askmenow · Post #2845 · 27.01.2021 г., 10:04

Today's Questions and Answers 1. Which is the coldest continent in the world? Answer: Antarctica 2. Which is the world’s smallest country? Answer: Vatican City 3. Where is the Colloseum located? Answer: Rome, Italy 4. Where is the Tower Bridge located? Answer: London, UK 5. Where is the Leaning Tower of Pisa located? Answer: Pisa, Italy #DidYouKnow There is enough DNA in the average person’s body to stretch from the sun to Pluto and back — 17 times. Via @askmenow Today's news headlines: read here Try: Quiz MCQ For Fun: Be Like Bro , sarcasticLOL

Hashtags

Ask Me

@askmenow · Post #2844 · 25.01.2021 г., 12:22

Today's Questions and Answers 1. Which is the largest waterfall in the world? Answer: Victoria Falls 2. Which is the largest desert in the world? Answer: Sahara Desert 3. What are the branches of a river called? Answer: Tributaries 4. Which is the largest island in the world? Answer: Greenland 5. What heats the water in a hot spring? Answer: Magma #DidYouKnow In a glass of water when you pour a handful of salt, the level of water does down Via @askmenow Today's news headlines: read here Try: Quiz MCQ For Fun: Be Like Bro , sarcasticLOL

Hashtags

Ask Me

@askmenow · Post #2843 · 24.01.2021 г., 06:32

Today's Questions and Answers 1. Which is the tallest mountain in the world? Answer: Mount Everest 2. Which is the latitude that runs through the centre of the Earth? Answer: Equator 3. What are the names of the 5 oceans of the world? Answer: Indian Ocean, Southern Ocean, Atlantic Ocean, Pacific Ocean, and Arctic Ocean 4. Which country has the highest population? Answer: China 5. Which is the longest river in the world? Answer: The Nile, Africa #DidYouKnow The Paris Agreement on climate change was signed by the largest number of countries ever in one day. Via @askmenow Today's news headlines: read here For fun visit : Be Like Bro , sarcasticLOL Try : Quiz MCQ

Hashtags

Ask Me

@askmenow · Post #2841 · 18.01.2021 г., 12:48

Daily Questions and Answers 1. Aurora Borealis are created in which layer of atmosphere? Ans. Thermosphere 2. What is the instrument used to measure wind speed? Ans. Anemometer 3. Eiffel Tower is six inches taller in summer due to- Ans. Thermal Expansion 4. Eiffel Tower is taller in which season- Ans. Summer Season 5. Who was the first person to win the Nobel prize in physics? Ans. Wilhelm Conrad Röntgen (1901) #DidYouKnow The reason the ocean has waves and has tides that switch from high to low is that the gravitational pull from the moon and the sun keep changing. Via @askmenow Know more about: 1- Aurora Borealis vs Aurora Australis Today's headlines: read here For fun: Visit @sarcasticLOL & @updateee

Hashtags

Ask Me

@askmenow · Post #2840 · 16.01.2021 г., 16:45

Daily Questions and Answers 1. Seasons on the Earth occur due to? Ans. Tilt of the Earth 2. Which scientist invented dynamite? Ans. Alfred Nobel 3. What is the full form of ISRO? Ans. Indian Space Research Organization 4. What is the speed of light? Ans. 300,000 kilometer per second or 3×108m/s 5. When the moon comes in between Earth and the Sun, it is called as? Ans. Solar eclipse #DidYouKnow No life form can survive if they were to enter a black hole, like the one at the centre of our galaxy, the Milky Way. Even light can’t survive in a black hole. Via@askmenow© For more Visit: Word Coach, News Clips, SarcasticLOL & Be Like Bro

Hashtags

Ask Me

@askmenow · Post #2839 · 15.01.2021 г., 10:12

Daily Questions and Answers 1. Sleeping under the tree at night time is dangerous because trees produce some gas, what is the gas? Ans. Carbon Dioxide 2. Sound waves cannot travel in? Ans. Space or Vacuum 3. What is the full form of NASA? Ans. National Aeronautics and Space Administration 4. What is the atomic number of sodium? Ans. 11 5. What are the three subatomic particles in an atom? Ans. Eelectrons, protons and neutrons #DidYouKnow The decimal number system we use today was invented in India. Via @askmenow Latest news: Hong Kong internet provider admits blocking pro-democracy website Have fun with @sarcasticLOL

Hashtags

Ask Me

@askmenow · Post #2837 · 14.01.2021 г., 07:12

Daily Questions and Answers 1. We live in which layer of atmosphere? Ans. Troposphere 2. 1 Nanometer is equals to how many meters? Ans. 10 power minus 9 meters 3. Sun appears red at morning and evening because of? Ans. Scattering of light 4. Which Scientist named the words positive and negative in electrical charges? Ans. Benjamin Franklin 5. A Reusable space rocket is called as? Ans. Space shuttle #DidYouKnow Dogs have an amazing sense of hearing and can hear sounds at four times the distance than humans can. Via @askmenow Latest news:Yellow mealworms become first insect approved in EU as human food Know more about:Mealworm

Hashtags

123•••10•••1617
ПретходнаСтраница 1 од 17Следна