Skip to content

Commit

Permalink
Merge pull request #459 from afshin/backport-5136
Browse files Browse the repository at this point in the history
Add descriptive log for port unavailable and port-retries=0
  • Loading branch information
blink1073 authored Mar 25, 2021
2 parents 6cad9ee + 5a5052e commit 500e94e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,11 +1145,6 @@ def _observe_contents_manager_class(self, change):
"until its next major release (2.x)."
)

@observe('notebook_dir')
def _update_notebook_dir(self, change):
self.log.warning(_i18n("notebook_dir is deprecated, use root_dir"))
self.root_dir = change['new']

kernel_manager_class = Type(
default_value=AsyncMappingKernelManager,
klass=MappingKernelManager,
Expand Down Expand Up @@ -1767,7 +1762,10 @@ def init_httpserver(self):
self.http_server.listen(port, self.ip)
except socket.error as e:
if e.errno == errno.EADDRINUSE:
self.log.info(_i18n('The port %i is already in use, trying another port.') % port)
if self.port_retries:
self.log.info(_i18n('The port %i is already in use, trying another port.') % port)
else:
self.log.info(_i18n('The port %i is already in use.') % port)
continue
elif e.errno in (errno.EACCES, getattr(errno, 'WSAEACCES', errno.EACCES)):
self.log.warning(_i18n("Permission to listen on port %i denied") % port)
Expand All @@ -1779,8 +1777,12 @@ def init_httpserver(self):
success = True
break
if not success:
self.log.critical(_i18n('ERROR: the Jupyter server could not be started because '
if self.port_retries:
self.log.critical(_i18n('ERROR: the notebook server could not be started because '
'no available port could be found.'))
else:
self.log.critical(_i18n('ERROR: the notebook server could not be started because '
'port %i is not available.') % port)
self.exit(1)

@staticmethod
Expand Down

0 comments on commit 500e94e

Please sign in to comment.