cleanup and wait for child processes
This commit is contained in:
parent
db8a7302a0
commit
4fb851c80e
@ -42,7 +42,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
systemd = None
|
systemd = None
|
||||||
|
|
||||||
if os.name == "posix":
|
if hasattr(os, "fork"):
|
||||||
ParallelizationMixIn = socketserver.ForkingMixIn
|
ParallelizationMixIn = socketserver.ForkingMixIn
|
||||||
else:
|
else:
|
||||||
ParallelizationMixIn = socketserver.ThreadingMixIn
|
ParallelizationMixIn = socketserver.ThreadingMixIn
|
||||||
@ -75,6 +75,9 @@ else:
|
|||||||
class ParallelHTTPServer(ParallelizationMixIn,
|
class ParallelHTTPServer(ParallelizationMixIn,
|
||||||
wsgiref.simple_server.WSGIServer):
|
wsgiref.simple_server.WSGIServer):
|
||||||
|
|
||||||
|
# wait for child processes/threads
|
||||||
|
_block_on_close = True
|
||||||
|
|
||||||
# These class attributes must be set before creating instance
|
# These class attributes must be set before creating instance
|
||||||
client_timeout = None
|
client_timeout = None
|
||||||
max_connections = None
|
max_connections = None
|
||||||
@ -311,14 +314,21 @@ def serve(configuration, shutdown_socket=None):
|
|||||||
# Fallback to busy waiting. (select.select blocks SIGINT on Windows.)
|
# Fallback to busy waiting. (select.select blocks SIGINT on Windows.)
|
||||||
select_timeout = 1.0
|
select_timeout = 1.0
|
||||||
logger.info("Radicale server ready")
|
logger.info("Radicale server ready")
|
||||||
while True:
|
|
||||||
rlist, _, xlist = select.select(sockets, [], sockets, select_timeout)
|
with contextlib.ExitStack() as stack:
|
||||||
if xlist:
|
for _, server in servers.items():
|
||||||
raise RuntimeError("unhandled socket error")
|
# close server
|
||||||
if shutdown_socket in rlist:
|
stack.push(server)
|
||||||
logger.info("Stopping Radicale")
|
while True:
|
||||||
break
|
rlist, _, xlist = select.select(
|
||||||
if rlist:
|
sockets, [], sockets, select_timeout)
|
||||||
server = servers.get(rlist[0])
|
if xlist:
|
||||||
if server:
|
raise RuntimeError("unhandled socket error")
|
||||||
server.handle_request()
|
if shutdown_socket in rlist:
|
||||||
|
logger.info("Stopping Radicale")
|
||||||
|
break
|
||||||
|
if rlist:
|
||||||
|
server = servers.get(rlist[0])
|
||||||
|
if server:
|
||||||
|
server.handle_request()
|
||||||
|
server.service_actions()
|
||||||
|
Loading…
Reference in New Issue
Block a user