我正在使用 Sanic (Python) 作为 Web 服务器,并面临一些请求的问题。当我们同时收到很多请求时,它会返回错误。错误描述如下:
web_1 | 2017-10-03 09:24:49 - (network)[INFO][172.17.0.1:55372]: GET http://localhost:8000/api/order_items/123456 200 38
web_1 | 2017-10-03 09:24:50 - (network)[INFO][172.17.0.1:55382]: GET http://localhost:8000/api/order_items/123456 200 38
web_1 | 2017-10-03 09:24:55 - (network)[INFO][172.17.0.1:55392]: GET http://localhost:8000/api/order_items/123456 200 38
web_1 | 2017-10-03 09:24:56 - (sanic)[ERROR]: Connection lost before response 2343 written @ ('172.17.0.1', 55402)
web_1 | 2017-10-03 09:24:56 - (network)[INFO][172.17.0.1:55412]: GET http://localhost:8000/api/order_items/123456 200 38
web_1 | 2017-10-03 09:24:57 - (sanic)[ERROR]: Connection lost before response 2343 written @ ('172.17.0.1', 55424)
web_1 | 2017-10-03 09:24:57 - (network)[INFO][172.17.0.1:55430]: GET http://localhost:8000/api/order_items/123456 200 38
这是 Sanic 报告此错误的地方: https ://github.com/channelcat/sanic/blob/master/sanic/server.py#L333
因此,根据我的理解,HTTP 连接在 Sanic 可以写入之前关闭,这很好,但如果我愿意,我应该能够覆盖行为并隐藏错误,这是我需要帮助的事情