Skip to content

Commit 3f99276

Browse files
committed
cached entire url, per nfelt's comment
1 parent c01fe3b commit 3f99276

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

tensorboard/program.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ def __init__(self, wsgi_app, flags):
597597
host = "localhost"
598598

599599
self._host = host
600-
self.display_host = None # Will be set by get_url() below
600+
self._url = None # Will be set by get_url() below
601601

602602
self._fix_werkzeug_logging()
603603
try:
@@ -728,30 +728,31 @@ def handle_error(self, request, client_address):
728728
logger.error("HTTP serving error", exc_info=exc_info)
729729

730730
def get_url(self):
731-
if not self.display_host:
731+
if not self._url:
732732
if self._auto_wildcard:
733-
self.display_host = socket.getfqdn()
733+
display_host = socket.getfqdn()
734734

735735
# Confirm that the connection is open, otherwise change to `localhost`
736736
try:
737737
socket.create_connection(
738-
(self.display_host, self.server_port), timeout=1
738+
(display_host, self.server_port), timeout=1
739739
)
740740
except socket.error as e:
741-
self.display_host = "localhost"
741+
display_host = "localhost"
742742

743743
else:
744744
host = self._host
745-
self.display_host = (
745+
display_host = (
746746
"[%s]" % host
747747
if ":" in host and not host.startswith("[")
748748
else host
749749
)
750-
return "http://%s:%d%s/" % (
751-
self.display_host,
752-
self.server_port,
753-
self._flags.path_prefix.rstrip("/"),
754-
)
750+
self._url = "http://%s:%d%s/" % (
751+
display_host,
752+
self.server_port,
753+
self._flags.path_prefix.rstrip("/"),
754+
)
755+
return self._url
755756

756757
def print_serving_message(self):
757758
if self._flags.host is None and not self._flags.bind_all:

0 commit comments

Comments
 (0)