From 487dc81295df60713d8843d00b5868883d48472d Mon Sep 17 00:00:00 2001 From: Julien Muchembled <jm@nexedi.com> Date: Wed, 16 May 2012 14:52:37 +0200 Subject: [PATCH] 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. --- product/ERP5Type/tests/custom_zodb.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/product/ERP5Type/tests/custom_zodb.py b/product/ERP5Type/tests/custom_zodb.py index 4914157a7e..bf42f92fb4 100644 --- a/product/ERP5Type/tests/custom_zodb.py +++ b/product/ERP5Type/tests/custom_zodb.py @@ -94,14 +94,21 @@ zeo_server_pid = None node_pid_list = [] ZEvent = sys.modules.get('ZServer.PubCore.ZEvent') +zrpc = sys.modules.get('ZEO.zrpc.connection') def fork(): pid = os.fork() if pid: - # recreate the event pipe if it already exists + # recreate event pipes that already exist for obj in socket_map.values(): - assert obj is ZEvent.the_trigger obj.close() - ZEvent.the_trigger = ZEvent.simple_trigger() + if obj is ZEvent.the_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 instance_random.seed(instance_random.random()) return pid @@ -160,7 +167,6 @@ else: break else: forkNodes() - # do not import ClientStorage before forking due to client trigger from ZEO.ClientStorage import ClientStorage Storage = ClientStorage(zeo_client) -- 2.30.9