Skip to content

Commit 8e7c99a

Browse files
embraySteven Silvester
andauthored
Workaround for socket permission errors on Cygwin (#4584)
* Workaround for wrong errno on socket bind permission errors on Cygwin. * [ci skip] Add period to comment Co-authored-by: Steven Silvester <[email protected]>
1 parent dbfa82c commit 8e7c99a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

notebook/notebookapp.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1725,13 +1725,20 @@ def _bind_http_server_tcp(self):
17251725
try:
17261726
self.http_server.listen(port, self.ip)
17271727
except socket.error as e:
1728+
eacces = (errno.EACCES, getattr(errno, 'WSAEACCES', errno.EACCES))
1729+
if sys.platform == 'cygwin':
1730+
# Cygwin has a bug that causes EPERM to be returned in this
1731+
# case instead of EACCES:
1732+
# https://cygwin.com/ml/cygwin/2019-04/msg00160.html
1733+
eacces += (errno.EPERM,)
1734+
17281735
if e.errno == errno.EADDRINUSE:
17291736
if self.port_retries:
17301737
self.log.info(_('The port %i is already in use, trying another port.') % port)
17311738
else:
17321739
self.log.info(_('The port %i is already in use.') % port)
17331740
continue
1734-
elif e.errno in (errno.EACCES, getattr(errno, 'WSAEACCES', errno.EACCES)):
1741+
elif e.errno in eacces:
17351742
self.log.warning(_("Permission to listen on port %i denied.") % port)
17361743
continue
17371744
else:

0 commit comments

Comments
 (0)