Commit 0330eda8 authored by Jim Fulton's avatar Jim Fulton

Don't use subprocess on windows. The close_fds option doesn't work on

windows and there's something aboyt the way we're setting up arguments
on windows that makes subproccess unhappy.

In the doctest support, save the pids along with adminaddrs and, when
we shutdown a server, wait for it to stop with os.waitpid. This is to
avoid a race where we end up trying and failing to delete the server's
log files before the server has closed them.
parent 3a716599
......@@ -129,6 +129,9 @@ def start_zeo_server(storage_conf=None, zeo_conf=None, port=None, keep=False,
d = os.environ.copy()
d['PYTHONPATH'] = os.pathsep.join(sys.path)
if sys.platform.startswith('win'):
pid = os.spawnve(os.P_NOWAIT, sys.executable, tuple(args), d)
else:
pid = subprocess.Popen(args, env=d, close_fds=True).pid
adminaddr = ('localhost', port + 1)
......@@ -270,7 +273,7 @@ def can_connect(port):
def setUp(test):
ZODB.tests.util.setUp(test)
servers = []
servers = {}
def start_server(storage_conf=None, zeo_conf=None, port=None, keep=False,
addr=None):
......@@ -285,10 +288,10 @@ def setUp(test):
port = addr[1]
elif addr is not None:
raise TypeError("Can't specify port and addr")
addr, adminaddr, _, config_path = start_zeo_server(
addr, adminaddr, pid, config_path = start_zeo_server(
storage_conf, zeo_conf, port, keep)
os.remove(config_path)
servers.append(adminaddr)
servers[adminaddr] = pid
return addr, adminaddr
test.globs['start_server'] = start_server
......@@ -299,15 +302,15 @@ def setUp(test):
test.globs['get_port'] = get_port
def stop_server(adminaddr):
servers.remove(adminaddr)
return shutdown_zeo_server(adminaddr)
pid = servers.pop(adminaddr)
shutdown_zeo_server(adminaddr)
os.waitpid(pid, 0)
test.globs['stop_server'] = stop_server
def cleanup_servers():
while servers:
adminaddr = servers.pop()
shutdown_zeo_server(adminaddr)
for adminaddr in list(servers):
stop_server(adminaddr)
zope.testing.setupstack.register(test, cleanup_servers)
......
Markdown is supported
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