Litestar consumes high amount of CPU #2504
-
DescriptionRunning litestar Is this normal or is there a way to reduce the idling CPU consumption? Attached a picture of cProfile. URL to code causing the issueNo response MCVEUVICORN_LOOP=uvloop litestar run
Using Litestar app from env: 'app.asgi:create_app'
Starting server process ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌──────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Litestar version │ 2.2.1 │
│ Debug mode │ Disabled │
│ Python Debugger on exception │ Disabled │
│ CORS │ Enabled │
│ CSRF │ Disabled │
│ OpenAPI │ Enabled path=/schema │
│ Compression │ Disabled │
│ Template engine │ ViteTemplateEngine │
│ Static files │ path=/static dirs=.../src/app/domain/web/public html_mode=Enabled │
│ Middlewares │ JWTCookieAuthenticationMiddleware, SentryLitestarASGIMiddleware, middleware_factory │
└──────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
2023-10-23T19:12:38.780745Z [info ] Started server process [4257] [uvicorn.error]
2023-10-23T19:12:38.781923Z [info ] Waiting for application startup. [uvicorn.error]
2023-10-23T19:12:38.789916Z [info ] Application startup complete. [uvicorn.error]
2023-10-23T19:12:38.792650Z [info ] Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) [uvicorn.error]
^C2023-10-23T19:15:04.770399Z [info ] Shutting down [uvicorn.error]
^C2023-10-23T19:15:04.910332Z [info ] Finished server process [4257] [uvicorn.error]
^C2023-10-23T19:15:04.974529Z [info ] ASGI 'lifespan' protocol appears unsupported. [uvicorn.error]
ScreenshotsLogsNo response Litestar Version2.2.1 Platform
Note While we are open for sponsoring on GitHub Sponsors and Check out all issues funded or available for funding on our Polar.sh Litestar dashboard
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I cannot reproduce this with a basic application. Can you provide a reproducible example? It’s really hard to debug this without actually know what your app looks like, but I’m fairly certain that there’s some kind of busy loop involved you’re not aware of. |
Beta Was this translation helpful? Give feedback.
@bpereto Thanks for the insightful report! I put up a fix over here #2547. Can you confirm this fixes your issue?