我有一个或多或少的处理程序:
async def handler(request):
response = web.StreamResponse(headers={
'Content-Type': 'text/plain; charset=utf-8',
'Connection': 'keep-alive',
})
response.enable_chunked_encoding()
await stream_response.prepare(request)
try:
await do_a_thing(response) # writes into response
except Exception as e:
# log the exception. I sometimes catch a CancelledError here
await response.write_eof()
return response
当没有出错时,页面生成正常。 当do_a_thing()中出现CancelledError时,浏览器会显示错误页面ERR_INCOMPLETE_CHUNKED_ENCODING,即使:
我必须做错事,或做错事,但我无法说清楚。
任何人都可以看到它可能是什么吗?