Skip to content

Commit a8e33d7

Browse files
committed
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 4258f75 commit a8e33d7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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
@@ -196,7 +197,7 @@ def make_simple_server(tb_app, host=None, port=None):
196197
tf.logging.error(msg)
197198
print(msg)
198199
raise socket_error
199-
200+
server.handle_error = _handle_error
200201
final_port = server.socket.getsockname()[1]
201202
tensorboard_url = 'http://%s:%d' % (final_host, final_port)
202203
return server, tensorboard_url
@@ -216,6 +217,18 @@ def run_simple_server(tb_app):
216217
server.serve_forever()
217218

218219

220+
# Kludge to override a SocketServer.py method so we can get rid of noisy
221+
# EPIPE errors. They're kind of a red herring as far as errors go. For
222+
# example, `curl -N http://localhost:6006/ | head` will cause an EPIPE.
223+
def _handle_error(unused_request, client_address):
224+
exc_info = sys.exc_info()
225+
e = exc_info[1]
226+
if isinstance(e, IOError) and e.errno == errno.EPIPE:
227+
tf.logging.warn('EPIPE caused by %s:%d in HTTP serving' % client_address)
228+
else:
229+
tf.logging.error('HTTP serving error', exc_info=exc_info)
230+
231+
219232
def main(unused_argv=None):
220233
util.setup_logging()
221234
if FLAGS.inspect:

0 commit comments

Comments
 (0)