]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Fix bind_sockets if OS does not support IPv6 823/head
authorschlamar <marc.schlaich@gmail.com>
Tue, 11 Jun 2013 12:38:32 +0000 (14:38 +0200)
committerschlamar <marc.schlaich@gmail.com>
Tue, 11 Jun 2013 12:38:32 +0000 (14:38 +0200)
tornado/netutil.py

index bbd11485a6bacffa33cefef8aace571f6c213dfb..3703718043d82e05b4ec4297f50daac79f31dcd3 100644 (file)
@@ -66,7 +66,12 @@ def bind_sockets(port, address=None, family=socket.AF_UNSPEC, backlog=128, flags
     for res in set(socket.getaddrinfo(address, port, family, socket.SOCK_STREAM,
                                       0, flags)):
         af, socktype, proto, canonname, sockaddr = res
-        sock = socket.socket(af, socktype, proto)
+        try:
+            sock = socket.socket(af, socktype, proto)
+        except socket.error as e:
+            if e.args[0] == errno.EAFNOSUPPORT:
+                continue
+            raise
         set_close_exec(sock.fileno())
         if os.name != 'nt':
             sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)