Commit 9acced19 authored by Vincent Pelletier's avatar Vincent Pelletier

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.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1786 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent e64b4317
...@@ -50,9 +50,8 @@ from neo.util import u64, parseMasterList ...@@ -50,9 +50,8 @@ from neo.util import u64, parseMasterList
class ThreadContext(object): class ThreadContext(object):
_threads_dict = {}
def __init__(self): def __init__(self):
super(ThreadContext, self).__setattr__('_threads_dict', {})
self.txn_info = 0 self.txn_info = 0
self.history = None self.history = None
self.node_tids = {} self.node_tids = {}
......
...@@ -939,6 +939,19 @@ class ClientApplicationTests(NeoTestBase): ...@@ -939,6 +939,19 @@ class ClientApplicationTests(NeoTestBase):
# check disabled since we reonnect to pmn # check disabled since we reonnect to pmn
#self.assertRaises(NEOStorageError, app._askPrimary, packet) #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__': if __name__ == '__main__':
unittest.main() unittest.main()
......
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