Commit 2bf1da0f authored by Jeremy Hylton's avatar Jeremy Hylton

Add new features from ZEO2.

Support for using basic multi framework with other run() functions.
parent 0017bbdc
...@@ -53,14 +53,17 @@ def start_server(addr): ...@@ -53,14 +53,17 @@ def start_server(addr):
pid, exit = forker.start_zeo_server(storage, addr) pid, exit = forker.start_zeo_server(storage, addr)
return pid, exit return pid, exit
def start_client(addr): def start_client(addr, client_func=None):
pid = os.fork() pid = os.fork()
if pid == 0: if pid == 0:
import ZEO.ClientStorage import ZEO.ClientStorage
if VERBOSE: if VERBOSE:
print "Client process started:", os.getpid() print "Client process started:", os.getpid()
cli = ZEO.ClientStorage.ClientStorage(addr, client=CLIENT_CACHE) cli = ZEO.ClientStorage.ClientStorage(addr, client=CLIENT_CACHE)
if client_func is None:
run(cli) run(cli)
else:
client_func(cli)
cli.close() cli.close()
os._exit(0) os._exit(0)
else: else:
...@@ -106,20 +109,14 @@ def run(storage): ...@@ -106,20 +109,14 @@ def run(storage):
print "Client completed:", pid print "Client completed:", pid
def shutdown_server(addr): def main(client_func=None):
import ZEO.ClientStorage
# XXX this doesn't work!
cli = ZEO.ClientStorage.ClientStorage(addr)
cli._server.rpc.callAsync('shutdown')
def main():
if VERBOSE: if VERBOSE:
print "Main process:", os.getpid() print "Main process:", os.getpid()
addr = tempfile.mktemp() addr = tempfile.mktemp()
t0 = time.time() t0 = time.time()
server_pid, server = start_server(addr) server_pid, server = start_server(addr)
t1 = time.time() t1 = time.time()
pids = [start_client(addr) for i in range(CLIENTS)] pids = [start_client(addr, client_func) for i in range(CLIENTS)]
for pid in pids: for pid in pids:
assert type(pid) == types.IntType, "invalid pid type: %s (%s)" % \ assert type(pid) == types.IntType, "invalid pid type: %s (%s)" % \
(repr(pid), type(pid)) (repr(pid), type(pid))
......
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