Comments (4)
I don't think this is related to the 100% cpu, but you should use asyncio.sleep instead of time.sleep (https://www.tornadoweb.org/en/stable/faq.html#id2).
Which version of python are you using?
How exactly are you setting up multi-process mode? I assume both of these profiles are from a child process?
from tornado.
I don't think this is related to the 100% cpu, but you should use asyncio.sleep instead of time.sleep (https://www.tornadoweb.org/en/stable/faq.html#id2).
I just use time.sleep to simply represent my real logic, which is actually a slow query of MySQL. If the user feels it is slow and closes the page, the CPU will rise to 100%. If the user is willing to continue waiting, it is normal. I shielded a machine and used requests to set different timeouts of 5s and 40s to simulate request verification, which was consistent with the above performance. When I set the timeout to 5 seconds, the CPU was abnormal while the server continued to execute, and there were no other requests at this time. When the timeout was set to 40s, the CPU was normal, and there were no other requests.
Which version of python are you using?
Python 3.6, in docker environment.
How exactly are you setting up multi-process mode? I assume both of these profiles are from a child process?
app = tornado.web.Application(APP_URLS)
http_server = tornado.httpserver.HTTPServer(app, xheaders=True)
http_server.listen(8080)
http_server.start(num_processes=2)
from tornado.
http_server.start
is used with http_server.bind
, not listen
. listen
is only for single-process mode and I think it might be able to cause problems like this when used in multi-process mode. Look at the docs for add_sockets
multi-process mode in the HTTPServer docs: https://www.tornadoweb.org/en/stable/httpserver.html#tornado.httpserver.HTTPServer (use add_sockets instead of bind/start because bind/start is deprecated for future versions of python)
from tornado.
Thanks, I tried the above method and it works fine now!
from tornado.
Related Issues (20)
- Test fail with openssl 3.2 HOT 1
- tornado.websocket.WebSocketClosedError HOT 1
- Send 204 as HTTPError
- Tornado Websocket write message performance degradation when binary is False HOT 2
- `Subprocess.wait_for_exit` never resolves if process terminated before it is called HOT 3
- Websocket Client Handshake URI issue HOT 1
- Questions about Copilot + Open Source Software Hierarchy
- tornado.httputil.HTTPServerRequest and tornado.web.RequestHandler HOT 1
- Please update to 3.11 HOT 1
- TypeError: WebSocketHandler.init() missing 2 required positional arguments: 'application' and 'request' HOT 3
- Under pytest 8.2.0, 'AsyncHTTPTestCase' has no attribute 'runTest' HOT 1
- 6.4.1: pytest fails in multiple nits with `AttributeError: 'TestIOStreamMixin' object has no attribute 'io_loop'` error HOT 3
- Vulnerability: GHSA-753j-mpmx-qq6g HOT 1
- Tornado version and version_info inconsistent HOT 2
- ValueError when If-Modified-Since is invalid for StaticFileHandler request HOT 7
- Tornado not sufficiently validating HTTP method HOT 2
- form data with &s in it breaks get_body_argument() HOT 3
- http server occasionally experiences high latency HOT 2
- `from __future__ import annotations` should be used HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tornado.