File indexing completed on 2026-04-10 08:38:58
0001 import taskbuffer.DBProxyPool
0002
0003 from pandaserver import taskbuffer
0004
0005 from . import JediDBProxy
0006
0007
0008 taskbuffer.DBProxyPool.DBProxy = JediDBProxy
0009
0010
0011 class DBProxyPool(taskbuffer.DBProxyPool.DBProxyPool):
0012
0013 def __init__(self, dbhost, dbpasswd, nConnection, useTimeout=False):
0014 taskbuffer.DBProxyPool.DBProxyPool.__init__(self, dbhost, dbpasswd, nConnection, useTimeout)
0015
0016
0017 def get(self):
0018 proxy_obj = DBProxyObj(db_proxy_pool=self)
0019 return proxy_obj
0020
0021
0022
0023 class DBProxyObj(object):
0024
0025 def __init__(self, db_proxy_pool):
0026 self.proxy_pool = db_proxy_pool
0027 self.proxy = None
0028
0029
0030 def __enter__(self):
0031 self.proxy = self.proxy_pool.getProxy()
0032 return self.proxy
0033
0034
0035 def __exit__(self, type, value, traceback):
0036 self.proxy_pool.putProxy(self.proxy)
0037 self.proxy = None