Skip to content

Commit b58a82d

Browse files
authored
Make EPIPE tracebacks go away (#595)
These errors aren't very helpful and they tend to fill up logs. They could be caused by something as innocent as `curl -N http://localhost:6006/ | head`. It could also be caused by firewalls, or perhaps the browser abruptly navigating somewhere else. So we wouldn't want users to mistake these as meaningful when troubleshooting.
1 parent a068cb5 commit b58a82d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Diff for: tensorboard/main.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from __future__ import division
2222
from __future__ import print_function
2323

24+
import errno
2425
import os
2526
import socket
2627
import sys
@@ -220,7 +221,7 @@ def make_simple_server(tb_app, host=None, port=None, path_prefix=None):
220221
tf.logging.error(msg)
221222
print(msg)
222223
raise socket_error
223-
224+
server.handle_error = _handle_error
224225
final_port = server.socket.getsockname()[1]
225226
tensorboard_url = 'http://%s:%d%s' % (final_host, final_port, path_prefix)
226227
return server, tensorboard_url
@@ -240,6 +241,18 @@ def run_simple_server(tb_app):
240241
server.serve_forever()
241242

242243

244+
# Kludge to override a SocketServer.py method so we can get rid of noisy
245+
# EPIPE errors. They're kind of a red herring as far as errors go. For
246+
# example, `curl -N http://localhost:6006/ | head` will cause an EPIPE.
247+
def _handle_error(unused_request, client_address):
248+
exc_info = sys.exc_info()
249+
e = exc_info[1]
250+
if isinstance(e, IOError) and e.errno == errno.EPIPE:
251+
tf.logging.warn('EPIPE caused by %s:%d in HTTP serving' % client_address)
252+
else:
253+
tf.logging.error('HTTP serving error', exc_info=exc_info)
254+
255+
243256
def main(unused_argv=None):
244257
util.setup_logging()
245258
if FLAGS.inspect:

0 commit comments

Comments
 (0)