diff --git a/python/pdo/common/block_store_manager.py b/python/pdo/common/block_store_manager.py index c705edb9..8865fa66 100644 --- a/python/pdo/common/block_store_manager.py +++ b/python/pdo/common/block_store_manager.py @@ -33,14 +33,20 @@ # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +import threading +__block_manager_lock__ = threading.Lock() __local_block_manager__ = None def local_block_manager() : global __local_block_manager__ + + __block_manager_lock__.acquire() if __local_block_manager__ is None : block_store_file = pconfig.shared_configuration(['StorageService','BlockStore'], "./blockstore.mdb") __local_block_manager__ = BlockStoreManager(block_store_file, True) + __block_manager_lock__.release() + return __local_block_manager__ # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX diff --git a/python/pdo/common/key_value.py b/python/pdo/common/key_value.py index 6d4787cf..b556a14e 100644 --- a/python/pdo/common/key_value.py +++ b/python/pdo/common/key_value.py @@ -25,12 +25,19 @@ import logging logger = logging.getLogger(__name__) +# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +import threading +__block_store_lock__ = threading.Lock() __block_store_initialized__ = False # ----------------------------------------------------------------- # ----------------------------------------------------------------- def KeyValueInitialize(block_store_file = None) : global __block_store_initialized__ + + __block_store_lock__.acquire() + if __block_store_initialized__ : raise Exception("duplicate block store initialization") @@ -41,6 +48,8 @@ def KeyValueInitialize(block_store_file = None) : kvs.block_store_open(block_store_file) __block_store_initialized__ = True + __block_store_lock__.release() + # ----------------------------------------------------------------- # ----------------------------------------------------------------- def KeyValueTerminate() :