New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error #71869
Comments
While saving, this error shows up and is whatever is saving gets saved twice- Traceback (most recent call last):
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\socket.py", line 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
[04/Aug/2016 17:25:59] "GET /api/importeop/ HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 51082)
Traceback (most recent call last):
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\socket.py", line 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\servers\basehttp.py", line 92, in handle_error
super(ServerHandler, self).handle_error()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py", line 625, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\servers\basehttp.py", line 99, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py", line 681, in __init__
self.handle()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle
handler.run(self.server.get_app())
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\Sushant Gahlot\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\simple_server.py", line 36, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split' |
The traceback looks like wsgiref.close() was called before handle_error() was called (perhaps for a second time?) We'll probably need a reproducer (as simple as possible please) to debug this further, which might be difficult since it may be tricky to simulate the windows error. But you might also want to, say, post to python-list and see if anyone can spot a problem with your code. Could it be that it is calling wsgiref.close at the wrong time? |
The code is actually quite simple, I'll post it over here- def import_eop(request):
with open('C:/Users/sg/Desktop/projects/drfapi/venv/drf/prices_companies_indices_transpose.csv') as f:
contents = f.readlines()
dates = contents[0]
dates = dates.split(",")
dates = dates[1:]
d = []
for i in range(len(dates)):
d.append(Dates(date=dates[i]))
Dates.objects.bulk_create(d)
companies = []
entry = []
for i in range(1, len(contents)):
csline = contents[i].split(",")
prices = csline[1:len(csline)]
company = csline[0]
prices =[float(x) for x in prices]
entry = (Endday(company=company, eop=prices))
entry.save()
f.close()
print('Saved to database')
return HttpResponse('Ok') Now as you see, I'm not even handling wsgiref.close() at all. This isn't a django issue since django community themselves pointed me to this direction. Let me know if I can be of any help. |
If the save is happening twice, that must mean that that method is getting called twice, and I'm guessing that the second time it is called wsgiref is closed and thus you get the error. But that's just a guess, your code snippet by itself isn't enough to see how everything fits together. |
There have been a few times when this code ran perfectly fine, without any errors whatsoever. So the structure is like this- This code reads a csv, processes it and save it in a model- class Endday(models.Model):
company = models.TextField(null=True)
eop = models.TextField(max_length=100000) Now the database is postgresql, as soon as save is called, data is posted there. This code runs fine on my colleague's computer(same code) but he has windows 7. Thinking this might be a windows error, I re-installed windows 10 from the scratch. But to no help. At last, I had to knock python's door. |
Also, since I re-installed everything, I got python 3.5 too |
Which browser do you use? How big is the CSV file? Modern browsers tend to do aggressive prefetching so this might be the cause here. |
The CSV is around 75 MB, not that big I guess. And I've tried Chrome, Edge and Firefox |
I use the following django view function also produce the same exception def sendFiles(request):
fileName = request.GET['fileName']
pathToFile = os.path.join(filesDir, fileName)
response = FileResponse(open(pathToFile, 'rb'))
Tested with sending file Git-2.8.4-32-bit.exe (29.8MB), if tested with sending file GitHubSetup.exe(670kb),then no exception occurred. the exception like the following return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] 您的主机中的软件中止了一个已建立的连接
。
[09/Aug/2016 10:30:13] "GET /FileHost/?fileName=Git-2.8.4-32-bit.exe HTTP/1.1" 5
00 59 Exception happened during processing of request from ('127.0.0.1', 62237)
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 138, in run
self.finish_response()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 180, in finish_response
self.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 274, in write
self.send_headers()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socket.py", lin
e 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] 您的主机中的软件中止了一个已建立的连接
。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 141, in run
self.handle_error()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\site-packages\d
jango\core\servers\basehttp.py", line 92, in handle_error
super(ServerHandler, self).handle_error()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 368, in handle_error
self.finish_response()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 180, in finish_response
self.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 274, in write
self.send_headers()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py
", line 625, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py
", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\site-packages\d
jango\core\servers\basehttp.py", line 99, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py
", line 681, in __init__
self.handle()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\site-packages\d
jango\core\servers\basehttp.py", line 179, in handle
handler.run(self.server.get_app())
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 144, in run
self.close()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\simple_
server.py", line 36, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------
[09/Aug/2016 10:30:13] "GET /FileHost/?fileName=Git-2.8.4-32-bit.exe HTTP/1.1" 2
00 8192
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 138, in run
self.finish_response()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 180, in finish_response
self.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 274, in write
self.send_headers()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socket.py", lin
e 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] 您的主机中的软件中止了一个已建立的连接
。
[09/Aug/2016 10:30:13] "GET /FileHost/?fileName=Git-2.8.4-32-bit.exe HTTP/1.1" 5
00 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 62229)
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 138, in run
self.finish_response()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 180, in finish_response
self.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 274, in write
self.send_headers()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socket.py", lin
e 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] 您的主机中的软件中止了一个已建立的连接
。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 141, in run
self.handle_error()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\site-packages\d
jango\core\servers\basehttp.py", line 92, in handle_error
super(ServerHandler, self).handle_error()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 368, in handle_error
self.finish_response()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 180, in finish_response
self.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 274, in write
self.send_headers()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py
", line 625, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py
", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\site-packages\d
jango\core\servers\basehttp.py", line 99, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py
", line 681, in __init__
self.handle()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\site-packages\d
jango\core\servers\basehttp.py", line 179, in handle
handler.run(self.server.get_app())
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 144, in run
self.close()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\simple_
server.py", line 36, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------
[09/Aug/2016 10:30:13] "GET /FileHost/?fileName=Git-2.8.4-32-bit.exe HTTP/1.1" 2
00 8192
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 138, in run
self.finish_response()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 180, in finish_response
self.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 274, in write
self.send_headers()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socket.py", lin
e 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] 您的主机中的软件中止了一个已建立的连接
。
[09/Aug/2016 10:30:13] "GET /FileHost/?fileName=Git-2.8.4-32-bit.exe HTTP/1.1" 5
00 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 62231)
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 138, in run
self.finish_response()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 180, in finish_response
self.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 274, in write
self.send_headers()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socket.py", lin
e 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] 您的主机中的软件中止了一个已建立的连接
。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 141, in run
self.handle_error()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\site-packages\d
jango\core\servers\basehttp.py", line 92, in handle_error
super(ServerHandler, self).handle_error()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 368, in handle_error
self.finish_response()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 180, in finish_response
self.write(data)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 274, in write
self.send_headers()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py
", line 625, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py
", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\site-packages\d
jango\core\servers\basehttp.py", line 99, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py
", line 681, in __init__
self.handle()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\site-packages\d
jango\core\servers\basehttp.py", line 179, in handle
handler.run(self.server.get_app())
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\handler
s.py", line 144, in run
self.close()
File "C:\Users\i\AppData\Local\Programs\Python\Python35-32\lib\wsgiref\simple_
server.py", line 36, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split' |
This error is a protocol error. It is the analog to WSAECONNRESET. In your case, I would expect a problem with the client uploading the file. It probably closes the connection after sending the data without waiting for the http response. |
Given that django is involved, it looks like it is most likely django that is calling the method after wsgiref is closed. This doesn't *look* like a stdlib problem from what we can see so far, but it certainly could be. We'd need a reproducer that didn't involve django to make any further progress from our side. |
As already stated, this error bubbles up from the TCP layer. It means that the tcp stack, for example, gave up resending a tcp frame and timed out, determining that the recipient was no longer listening. |
Kristján: right, what I'm saying about the possible bug is the final part of the traceback resulting from (apparently) wsgiref being closed and a new operation being attempted. *Probably* that is a django bug in handling a network error, but maybe it is a wsgiref bug in handling the network error. (I'm assuming here that the Windows error is triggered by the retry, but I could of course be completely wrong about that.) |
I'm still seeing this with Python 3.6.3 Was this determined to be a Django bug? |
I think this is an issue with wsgiref handling client closure rather than a Windows/Django bug. I saw this sporadically but not consistently while running PR link : #9713 Sample traceback while serving docs locally with 127.0.0.1 - - [12/Oct/2018 10:56:57] "GET /_sources/library/asyncio-eventloop.rst.txt HTTP/1.1" 500 59 Exception happened during processing of request from ('127.0.0.1', 50436)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 138, in run
self.finish_response()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 274, in write
self.send_headers()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 332, in send_headers
self.send_preamble()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 453, in _write
result = self.stdout.write(data)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 796, in write
self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 141, in run
self.handle_error()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 368, in handle_error
self.finish_response()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 274, in write
self.send_headers()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 313, in _handle_request_noblock
self.process_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 344, in process_request
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 357, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 717, in __init__
self.handle()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/simple_server.py", line 133, in handle
handler.run(self.server.get_app())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/handlers.py", line 144, in run
self.close()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/wsgiref/simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split' Thanks |
The Github pull request #9713 addresses this. |
This seems like a bug in wsgiref.BaseHandler to me. BaseHandler.run() calls handle_error() if an error occurs inside finish_response(): cpython/Lib/wsgiref/handlers.py Line 141 in e2ed5ad
However, finish_response() calls close() in its finally block: cpython/Lib/wsgiref/handlers.py Lines 177 to 183 in e2ed5ad
|
There seem to be at least two different issues raised here (and in bpo-34547):
|
That's right. |
The pull request solves this problem, but the discussion over there is really slow. |
Thank you! |
The following message can still appear in the log when running the Django development server: ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 50713)
Traceback (most recent call last):
File "d:\python37\Lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "d:\python37\Lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "d:\python37\Lib\socketserver.py", line 720, in __init__
self.handle()
File "D:\Virtualenvs\***\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "D:\Virtualenvs\***\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "d:\python37\Lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine This is much better than before but even this message is completely uninteresting as web browsers disconnect from servers all the time. However, this could be better to fix in Django. |
Could potentially already be fixed in Django: django/django@7785e03#diff-f6d1c75ec606389da5af6558bf57f171L51 |
No it is not fixed in Django, but I verified that adding ConnectionAbortedError on this line fixes the error. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: