Show More
@@ -574,30 +574,6 b' class NotebookApp(BaseIPythonApplication):' | |||||
574 | try: |
|
574 | try: | |
575 | self.http_server.listen(port, self.ip) |
|
575 | self.http_server.listen(port, self.ip) | |
576 | except socket.error as e: |
|
576 | except socket.error as e: | |
577 | # XXX: remove the e.errno == -9 block when we require |
|
|||
578 | # tornado >= 3.0 |
|
|||
579 | if e.errno == -9 and tornado.version_info[0] < 3: |
|
|||
580 | # The flags passed to socket.getaddrinfo from |
|
|||
581 | # tornado.netutils.bind_sockets can cause "gaierror: |
|
|||
582 | # [Errno -9] Address family for hostname not supported" |
|
|||
583 | # when the interface is not associated, for example. |
|
|||
584 | # Changing the flags to exclude socket.AI_ADDRCONFIG does |
|
|||
585 | # not cause this error, but the only way to do this is to |
|
|||
586 | # monkeypatch socket to remove the AI_ADDRCONFIG attribute |
|
|||
587 | saved_AI_ADDRCONFIG = socket.AI_ADDRCONFIG |
|
|||
588 | self.log.warn('Monkeypatching socket to fix tornado bug') |
|
|||
589 | del(socket.AI_ADDRCONFIG) |
|
|||
590 | try: |
|
|||
591 | # retry the tornado call without AI_ADDRCONFIG flags |
|
|||
592 | self.http_server.listen(port, self.ip) |
|
|||
593 | except socket.error as e2: |
|
|||
594 | e = e2 |
|
|||
595 | else: |
|
|||
596 | self.port = port |
|
|||
597 | success = True |
|
|||
598 | break |
|
|||
599 | # restore the monekypatch |
|
|||
600 | socket.AI_ADDRCONFIG = saved_AI_ADDRCONFIG |
|
|||
601 | if e.errno == errno.EADDRINUSE: |
|
577 | if e.errno == errno.EADDRINUSE: | |
602 | self.log.info('The port %i is already in use, trying another random port.' % port) |
|
578 | self.log.info('The port %i is already in use, trying another random port.' % port) | |
603 | continue |
|
579 | continue |
General Comments 0
You need to be logged in to leave comments.
Login now