Closed socket error (broken pipe) on REST socket not handled gracefully (with traceback on stderr)
Hi,
when a socket is closed prematurely, for instance by my "are you alive script", I get tracebacks:
Example:
printf 'HEAD / HTTP/1.0\r\n\r\n' |
nc -w1 -q0 127.0.0.1 8001 |
grep -q '^HTTP/1.0 404' || echo mailman3 fail
Normally I use -q1
(which fails some times when the server is slow), but for the example, I lowered it to -q0
to make it trigger faster.
Mailman version: mailman==3.0.0
When it fails, because netcat quits before it has a chance to write anything, I get this [1] traceback on STDERR of the console I started mailman on.
-
Why do I get this on stderr? I browsed through the mailman.cfg and https://github.com/trevor/mailman3/blob/master/src/mailman/commands/docs/conf.rst but I don't see an easy way to get tracebacks e-mailed to me. Getting them on the console that happened to have started mailman sounds wrong.
-
Shouldn't a simple early client disconnect be handled more gracefully? E.g. by ignoring the error and writing the (unofficial, but common) status code 499 to mailman.log.
Aug 21 10:04:58 2015 (15218) 127.0.0.1 - - "HEAD / HTTP/1.0" 499 0
Thanks, Walter Doekes
[1]
Exception happened during processing of request from ('127.0.0.1', 42170)
Traceback (most recent call last):
File "/usr/lib/python3.4/wsgiref/handlers.py", line 138, in run
self.finish_response()
File "/usr/lib/python3.4/wsgiref/handlers.py", line 181, in finish_response
self.finish_content()
File "/usr/lib/python3.4/wsgiref/handlers.py", line 310, in finish_content
self.send_headers()
File "/usr/lib/python3.4/wsgiref/handlers.py", line 333, in send_headers
self._write(bytes(self.headers))
File "/usr/lib/python3.4/wsgiref/handlers.py", line 453, in _write
self.stdout.write(data)
File "/usr/lib/python3.4/socket.py", line 391, in write
return self._sock.send(b)
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.4/wsgiref/handlers.py", line 141, in run
self.handle_error()
File "/usr/lib/python3.4/wsgiref/handlers.py", line 368, in handle_error
self.finish_response()
File "/usr/lib/python3.4/wsgiref/handlers.py", line 180, in finish_response
self.write(data)
File "/usr/lib/python3.4/wsgiref/handlers.py", line 274, in write
self.send_headers()
File "/usr/lib/python3.4/wsgiref/handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "/usr/lib/python3.4/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 "/usr/lib/python3.4/socketserver.py", line 305, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python3.4/socketserver.py", line 331, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python3.4/socketserver.py", line 344, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python3.4/socketserver.py", line 669, in __init__
self.handle()
File "/usr/lib/python3.4/wsgiref/simple_server.py", line 133, in handle
handler.run(self.server.get_app())
File "/usr/lib/python3.4/wsgiref/handlers.py", line 144, in run
self.close()
File "/usr/lib/python3.4/wsgiref/simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------