Quiet handling and better message on unix socket bind error too.
This commit is contained in:
parent
e6c0f3990c
commit
69d493abce
|
@ -47,10 +47,10 @@ def bind_unix_socket(path: str, *, mode=0o666, backlog=100) -> socket.socket:
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
folder = os.path.dirname(path)
|
folder = os.path.dirname(path)
|
||||||
if not os.path.isdir(folder):
|
if not os.path.isdir(folder):
|
||||||
raise FileNotFoundError(f"Socket folder does not exist: {folder}")
|
raise FileNotFoundError("Socket folder does not exist")
|
||||||
try:
|
try:
|
||||||
if not stat.S_ISSOCK(os.stat(path, follow_symlinks=False).st_mode):
|
if not stat.S_ISSOCK(os.stat(path, follow_symlinks=False).st_mode):
|
||||||
raise FileExistsError(f"Existing file is not a socket: {path}")
|
raise FileExistsError("Existing file is not a socket")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
# Create new socket with a random temporary name
|
# Create new socket with a random temporary name
|
||||||
|
@ -103,7 +103,10 @@ def configure_socket(
|
||||||
unix = server_settings["unix"]
|
unix = server_settings["unix"]
|
||||||
backlog = server_settings["backlog"]
|
backlog = server_settings["backlog"]
|
||||||
if unix:
|
if unix:
|
||||||
sock = bind_unix_socket(unix, backlog=backlog)
|
try:
|
||||||
|
sock = bind_unix_socket(unix, backlog=backlog)
|
||||||
|
except OSError as e:
|
||||||
|
raise ServerError(f"Error binding {unix}: {e}", quiet=True)
|
||||||
server_settings["unix"] = unix
|
server_settings["unix"] = unix
|
||||||
if sock is None:
|
if sock is None:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user