Skip to content

Commit

Permalink
Bind the HTTPServer in start (#6061)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
minrk authored May 13, 2021
1 parent c1101de commit 80eb286
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1792,12 +1792,6 @@ def init_webapp(self):
max_body_size=self.max_body_size,
max_buffer_size=self.max_buffer_size)

success = self._bind_http_server()
if not success:
self.log.critical(_('ERROR: the notebook server could not be started because '
'no available port could be found.'))
self.exit(1)

def _bind_http_server(self):
return self._bind_http_server_unix() if self.sock else self._bind_http_server_tcp()

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

success = self._bind_http_server()
if not success:
self.log.critical(_('ERROR: the notebook server could not be started because '
'no available port could be found.'))
self.exit(1)

info = self.log.info
for line in self.notebook_info(kernel_count=False).split("\n"):
info(line)
Expand Down

0 comments on commit 80eb286

Please sign in to comment.