High CPU usage when using --reload
See original GitHub issueUsing the example code
async def app(scope, receive, send):
assert scope['type'] == 'http'
await send({
'type': 'http.response.start',
'status': 200,
'headers': [
[b'content-type', b'text/plain'],
],
})
await send({
'type': 'http.response.body',
'body': b'Hello, world!',
})
and running uvicorn main:app
, CPU usage is unnoticeable (less than 1% of 1 core).
But when running with uvicorn main:app --reload
, CPU usage jumps to 54% of 1 core.
Environment:
python -V
: Python 3.7.2
uvicorn
: 0.6.1
uname -a
: Linux architect 5.0.4-arch1-1-ARCH #1 SMP PREEMPT Sat Mar 23 21:00:33 UTC 2019 x86_64 GNU/Linux
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:27 (15 by maintainers)
Top Results From Across the Web
How to Fix High CPU Usage - Intel
Find out all the reasons why your PC displays high CPU usage. Our step-by-step guide will show you how to fix your CPU...
Read more >Desktop & Apps keep Refreshing, CPU usage going crazy
Hi, for about 2 weeks I my Windows 10 has been having the following issue: The desktop disappears and reappears frequently (as if...
Read more >CPU usage near 100% when loading/reloading a tab in the ...
CPU usage should show close to 100% while the browser is focused on the tab ... or reloading in the background should load...
Read more >High CPU usage during UI reload - Elder Scrolls Online forums
Sounds like a RAM or VRAM issue to me. If you have 8 gb or less RAM and keep lots of programs open...
Read more >CPU Usage high on one core. Reload didn't fix [SOLVED]
It could be a problem of a very high squid hard disk cache. On start of squid this can cause a high CPU...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found that there are
--reload-dir
settings already. By applying app folder, CPU usage significant decrease.I had this issue with my project.
With only
--reload
, it was eating up 25% of a 4 core CPU watching 8135 files in myvenv/
folder.By adding
--reload-dir src/
wheresrc/
contains my application, the CPU issue went away completely.Maybe a decent solution is to have uvicorn ignore common virtualenv directory names, like
venv/
.venv/
, etc?