sanic.exceptions.RequestTimeout: Sanic请求超时
sanic.exceptions.RequestTimeout: Request Timeout in Sanic
我 运行 sanic 应用程序,即使没有任何请求进入,它也会每隔几秒引发一次异常。
sanic.exceptions.RequestTimeout: Request Timeout
如何解决这个问题?
问题出在连接仍然有效的事实。添加以下配置似乎解决了我的问题
from sanic.config import Config
Config.KEEP_ALIVE = False
我会向您指出 the documentation 以便您了解自己在做什么以及为什么会收到该异常。一味的把KEEP_ALIVE
改成False
未必是你想要的
The KEEP_ALIVE config variable is set to True in Sanic by default. If you don’t need this feature in your application, set it to False to cause all client connections to close immediately after a response is sent, regardless of the Keep-Alive header on the request.
The amount of time the server holds the TCP connection open is decided by the server itself. In Sanic, that value is configured using the KEEP_ALIVE_TIMEOUT value. By default, it is set to 5 seconds, this is the same default setting as the Apache HTTP server and is a good balance between allowing enough time for the client to send a new request, and not holding open too many connections at once. Do not exceed 75 seconds unless you know your clients are using a browser which supports TCP connections held open for that long.
我 运行 sanic 应用程序,即使没有任何请求进入,它也会每隔几秒引发一次异常。
sanic.exceptions.RequestTimeout: Request Timeout
如何解决这个问题?
问题出在连接仍然有效的事实。添加以下配置似乎解决了我的问题
from sanic.config import Config
Config.KEEP_ALIVE = False
我会向您指出 the documentation 以便您了解自己在做什么以及为什么会收到该异常。一味的把KEEP_ALIVE
改成False
未必是你想要的
The KEEP_ALIVE config variable is set to True in Sanic by default. If you don’t need this feature in your application, set it to False to cause all client connections to close immediately after a response is sent, regardless of the Keep-Alive header on the request.
The amount of time the server holds the TCP connection open is decided by the server itself. In Sanic, that value is configured using the KEEP_ALIVE_TIMEOUT value. By default, it is set to 5 seconds, this is the same default setting as the Apache HTTP server and is a good balance between allowing enough time for the client to send a new request, and not holding open too many connections at once. Do not exceed 75 seconds unless you know your clients are using a browser which supports TCP connections held open for that long.