Commit 487dc812 authored by Julien Muchembled's avatar Julien Muchembled

Fix use of ZEO in unit tests when TIDStorage product is present

TIDStorage monkey-patches ZEO so it imported it before 'custom_zodb' is loaded.
This commit fix 'custom_zodb' to reset ZEO triggers.
parent a80728c4
...@@ -94,14 +94,21 @@ zeo_server_pid = None ...@@ -94,14 +94,21 @@ zeo_server_pid = None
node_pid_list = [] node_pid_list = []
ZEvent = sys.modules.get('ZServer.PubCore.ZEvent') ZEvent = sys.modules.get('ZServer.PubCore.ZEvent')
zrpc = sys.modules.get('ZEO.zrpc.connection')
def fork(): def fork():
pid = os.fork() pid = os.fork()
if pid: if pid:
# recreate the event pipe if it already exists # recreate event pipes that already exist
for obj in socket_map.values(): for obj in socket_map.values():
assert obj is ZEvent.the_trigger
obj.close() obj.close()
if obj is ZEvent.the_trigger:
ZEvent.the_trigger = ZEvent.simple_trigger() ZEvent.the_trigger = ZEvent.simple_trigger()
else:
assert obj is zrpc.ManagedServerConnection.trigger
zrpc.ManagedServerConnection.trigger = zrpc.trigger()
zrpc.ManagedClientConnection.trigger.close()
zrpc.ManagedClientConnection.trigger = \
zrpc.client_trigger = zrpc.trigger(zrpc.client_map)
# make sure parent and child have 2 different RNG # make sure parent and child have 2 different RNG
instance_random.seed(instance_random.random()) instance_random.seed(instance_random.random())
return pid return pid
...@@ -160,7 +167,6 @@ else: ...@@ -160,7 +167,6 @@ else:
break break
else: else:
forkNodes() forkNodes()
# do not import ClientStorage before forking due to client trigger
from ZEO.ClientStorage import ClientStorage from ZEO.ClientStorage import ClientStorage
Storage = ClientStorage(zeo_client) Storage = ClientStorage(zeo_client)
......
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