提交 9dadb8f4 编写于 作者: S Steven Li

Added mixed connector type for NATIVE/REST for the crash_gen tool

上级 2f8714e5
...@@ -84,8 +84,17 @@ class WorkerThread: ...@@ -84,8 +84,17 @@ class WorkerThread:
# Let us have a DB connection of our own # Let us have a DB connection of our own
if (gConfig.per_thread_db_connection): # type: ignore if (gConfig.per_thread_db_connection): # type: ignore
# print("connector_type = {}".format(gConfig.connector_type)) # print("connector_type = {}".format(gConfig.connector_type))
self._dbConn = DbConn.createNative() if ( if gConfig.connector_type == 'native':
gConfig.connector_type == 'native') else DbConn.createRest() self._dbConn = DbConn.createNative()
elif gConfig.connector_type == 'rest':
self._dbConn = DbConn.createRest()
elif gConfig.connector_type == 'mixed':
if Dice.throw(2) == 0: # 1/2 chance
self._dbConn = DbConn.createNative()
else:
self._dbConn = DbConn.createRest()
else:
raise RuntimeError("Unexpected connector type: {}".format(gConfig.connector_type))
self._dbInUse = False # if "use db" was executed already self._dbInUse = False # if "use db" was executed already
...@@ -528,7 +537,7 @@ class LinearQueue(): ...@@ -528,7 +537,7 @@ class LinearQueue():
class DbConn: class DbConn:
TYPE_NATIVE = "native-c" TYPE_NATIVE = "native-c"
TYPE_REST = "rest-api" TYPE_REST = "rest-api"
TYPE_INVALID = "invalid" TYPE_INVALID = "invalid"
@classmethod @classmethod
...@@ -735,7 +744,7 @@ class MyTDSql: ...@@ -735,7 +744,7 @@ class MyTDSql:
class DbConnNative(DbConn): class DbConnNative(DbConn):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self._type = self.TYPE_REST self._type = self.TYPE_NATIVE
self._conn = None self._conn = None
self._cursor = None self._cursor = None
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册