Skip to content

Commit 80eb286

Browse files
authored
Bind the HTTPServer in start (#6061)
Binding sockets hooks them up to the running eventloop, which we should try to avoid in initialize in case any other stages may configure the event loop policy
1 parent c1101de commit 80eb286

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

notebook/notebookapp.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1792,12 +1792,6 @@ def init_webapp(self):
17921792
max_body_size=self.max_body_size,
17931793
max_buffer_size=self.max_buffer_size)
17941794

1795-
success = self._bind_http_server()
1796-
if not success:
1797-
self.log.critical(_('ERROR: the notebook server could not be started because '
1798-
'no available port could be found.'))
1799-
self.exit(1)
1800-
18011795
def _bind_http_server(self):
18021796
return self._bind_http_server_unix() if self.sock else self._bind_http_server_tcp()
18031797

@@ -2297,6 +2291,12 @@ def start(self):
22972291
self.log.critical(_("Running as root is not recommended. Use --allow-root to bypass."))
22982292
self.exit(1)
22992293

2294+
success = self._bind_http_server()
2295+
if not success:
2296+
self.log.critical(_('ERROR: the notebook server could not be started because '
2297+
'no available port could be found.'))
2298+
self.exit(1)
2299+
23002300
info = self.log.info
23012301
for line in self.notebook_info(kernel_count=False).split("\n"):
23022302
info(line)

0 commit comments

Comments
 (0)