mirror of
https://github.com/django/daphne.git
synced 2024-11-22 07:56:34 +03:00
Unix socket fix (#161)
Fix error on listeners when passing a unix socket
This commit is contained in:
parent
3bffe981f6
commit
d46429247f
|
@ -131,7 +131,9 @@ class Server(object):
|
||||||
Called when a listen succeeds so we can store port details (if there are any)
|
Called when a listen succeeds so we can store port details (if there are any)
|
||||||
"""
|
"""
|
||||||
if hasattr(port, "getHost"):
|
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):
|
def listen_error(self, failure):
|
||||||
logger.critical("Listen failure: %s", failure.getErrorMessage())
|
logger.critical("Listen failure: %s", failure.getErrorMessage())
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import errno
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
|
@ -31,7 +32,7 @@ class DaphneTestingInstance:
|
||||||
try:
|
try:
|
||||||
s.bind(("127.0.0.1", port))
|
s.bind(("127.0.0.1", port))
|
||||||
except socket.error as e:
|
except socket.error as e:
|
||||||
if e.errno in [13, 98]:
|
if e.errno in [errno.EACCES, errno.EADDRINUSE]:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Reference in New Issue
Block a user