Unix socket fix (#161)

Fix error on listeners when passing a unix socket
This commit is contained in:
Jonas Lidén 2018-02-06 09:04:44 +01:00 committed by Andrew Godwin
parent 3bffe981f6
commit d46429247f
2 changed files with 5 additions and 2 deletions

View File

@ -131,7 +131,9 @@ class Server(object):
Called when a listen succeeds so we can store port details (if there are any)
"""
if hasattr(port, "getHost"):
self.listening_addresses.append((port.getHost().host, port.getHost().port))
host = port.getHost()
if hasattr(host, "host") and hasattr(host, "port"):
self.listening_addresses.append((host.host, host.port))
def listen_error(self, failure):
logger.critical("Listen failure: %s", failure.getErrorMessage())

View File

@ -1,3 +1,4 @@
import errno
import random
import socket
import struct
@ -31,7 +32,7 @@ class DaphneTestingInstance:
try:
s.bind(("127.0.0.1", port))
except socket.error as e:
if e.errno in [13, 98]:
if e.errno in [errno.EACCES, errno.EADDRINUSE]:
return True
else:
raise