最近有一个bug很有意思,说的是开发环境的时候,加载某个页面的时候,django 的runserver 会报
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 273, in run
self.finish_response()
File "/usr/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 312, in finish_response
self.write(data)
File "/usr/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 391, in write
self.send_headers()
File "/usr/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 443, in send_headers
self.send_preamble()
File "/usr/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 373, in send_preamble
'Date: %s\r\n' % time.asctime(time.gmtime(time.time()))
File "/usr/lib/python2.7/socket.py", line 261, in write
self.flush()
File "/usr/lib/python2.5/socket.py", line 248, in flush
self._sock.sendall(buffer)
error: (32, 'Broken pipe')
broken pipe 这个错误没怎么见过,放狗搜索得知:
写道
This is common error which happens whenever your browser closes the connection while the dev server is still busy sending data. The best we could is to have a more explicit error message.
意思就是 当服务端还没回写完数据,浏览器就把连接给关了。所以我就怀疑是否和页面上的js ajax调用有关: 异步调用没有写完,页面又被刷新了。
结果仔细一看,某某同学还真是粗心,改写了 form button的click事件却忘了把原先的行为给禁止掉,简单的说就是少了event.preventDefault(),但是某某同学的form又不写 action,所以从结果上来看页面这块还没啥错,只提交一次表单,只是页面整个被刷新了。