Skip to content

Commit e05a4df

Browse files
committed
Workaround for wrong errno on socket bind permission errors on Cygwin.
1 parent eea37a6 commit e05a4df

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
@@ -1441,10 +1441,17 @@ def init_webapp(self):
14411441
try:
14421442
self.http_server.listen(port, self.ip)
14431443
except socket.error as e:
1444+
eacces = (errno.EACCES, getattr(errno, 'WSAEACCES', errno.EACCES))
1445+
if sys.platform == 'cygwin':
1446+
# Cygwin has a bug that causes EPERM to be returned in this
1447+
# case instead of EACCES:
1448+
# https://cygwin.com/ml/cygwin/2019-04/msg00160.html
1449+
eacces += (errno.EPERM,)
1450+
14441451
if e.errno == errno.EADDRINUSE:
14451452
self.log.info(_('The port %i is already in use, trying another port.') % port)
14461453
continue
1447-
elif e.errno in (errno.EACCES, getattr(errno, 'WSAEACCES', errno.EACCES)):
1454+
elif e.errno in eacces:
14481455
self.log.warning(_("Permission to listen on port %i denied") % port)
14491456
continue
14501457
else:

0 commit comments

Comments
 (0)