[Neo-report] r1786 vincent - in /trunk/neo: client/app.py tests/client/testClientApp.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Feb 17 09:43:13 CET 2010
Author: vincent
Date: Wed Feb 17 09:43:11 2010
New Revision: 1786
Log:
Fix inter-app-instance thread locals visibility.
This causes isolation problems in tests (and was detected because of this)
but would have also caused problem if multiple Storage (and hence App class)
instances were used in a single process.
Modified:
trunk/neo/client/app.py
trunk/neo/tests/client/testClientApp.py
Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Wed Feb 17 09:43:11 2010
@@ -50,9 +50,8 @@
class ThreadContext(object):
- _threads_dict = {}
-
def __init__(self):
+ super(ThreadContext, self).__setattr__('_threads_dict', {})
self.txn_info = 0
self.history = None
self.node_tids = {}
Modified: trunk/neo/tests/client/testClientApp.py
==============================================================================
--- trunk/neo/tests/client/testClientApp.py [iso-8859-1] (original)
+++ trunk/neo/tests/client/testClientApp.py [iso-8859-1] Wed Feb 17 09:43:11 2010
@@ -939,6 +939,19 @@
# check disabled since we reonnect to pmn
#self.assertRaises(NEOStorageError, app._askPrimary, packet)
+ def test_threadContextIsolation(self):
+ """ Thread context properties must not be visible accross instances
+ while remaining in the same thread """
+ app1 = self.getApp()
+ app1_local = app1.local_var
+ app2 = self.getApp()
+ app2_local = app2.local_var
+ property_id = 'thread_context_test'
+ self.assertFalse(hasattr(app1_local, property_id))
+ self.assertFalse(hasattr(app2_local, property_id))
+ setattr(app1_local, property_id, 'value')
+ self.assertTrue(hasattr(app1_local, property_id))
+ self.assertFalse(hasattr(app2_local, property_id))
if __name__ == '__main__':
unittest.main()
More information about the Neo-report
mailing list