问题描述:
写了很久的django项目发现报错,但是整个项目却能正常运行,很是奇怪,特此记录,报错如下:
Traceback (most recent call last):
File "G:\anaconda\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "G:\anaconda\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "G:\anaconda\lib\socketserver.py", line 696, in __init__
self.handle()
File "F:\django_learn_project3\mysite\venv\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
self.handle_one_request()
File "F:\django_learn_project3\mysite\venv\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "G:\anaconda\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "F:\django_learn_project3\mysite\venv\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
super().close()
File "G:\anaconda\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
解决方案:
打开python\lib\wsgiref\simple_server.py文件,close方法,修改后如下
class ServerHandler(SimpleHandler):
server_software = software_version
def close(self):
try:
self.request_handler.log_request(
self.status.split(' ', 1)[0], self.bytes_sent
)
SimpleHandler.close(self)
except Exception as e:
SimpleHandler.close(self)