Commit e99bc84f authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Detect the running wav2mp3d daemon faster if we need to spawn it.

Also, raise InternalError if the daemon fails to start quickly enough.
parent 36ca69f8
......@@ -48,6 +48,10 @@ class MethodNotAllowed(Response):
def __init__(self, allowed):
super().__init__("405 Method Not Allowed", [('Allow', allowed)])
class InternalError(Response):
def __init__(self, reason):
super().__init__("500 " + reason, [])
class MovedPermanently(Response):
def __init__(self, location):
super().__init__("301 Moved Permanently", [("Location", location)])
......@@ -106,9 +110,15 @@ def get_daemon_connection():
c = multiprocessing.connection.Client(mp3wavcfg.socketpath, 'AF_UNIX')
return c
for i in range(200):
return multiprocessing.connection.Client(mp3wavcfg.socketpath,
except (FileNotFoundError, ConnectionRefusedError):
raise InternalError("failed to start wav2mp3d")
def convert(environ, start_response, ph):
if len(ph.op_args()) > 0:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment