未验证 提交 8ac6495d 编写于 作者: H Hui Li 提交者: GitHub

Merge pull request #13873 from taosdata/test/chr/TD-14699

test:modify testcase of muti-mnode
......@@ -23,39 +23,6 @@ class MyDnodes(TDDnodes):
self.dnodes = dnodes_lists # dnode must be TDDnode instance
self.simDeployed = False
class MyThreadFunc(object):
'''
手动终止线程的方法
'''
def __init__(self, func):
self.myThread = threading.Thread(target=func)
def start(self):
print('线程启动')
self.myThread.start()
def stop(self):
print('线程终止')
try:
for i in range(5):
self._async_raise(self.myThread.ident, SystemExit)
time.sleep(1)
except Exception as e:
print(e)
def _async_raise(self, tid, exctype):
"""raises the exception, performs cleanup if needed"""
tid = ctypes.c_long(tid)
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed")
class TDTestCase:
......@@ -87,6 +54,23 @@ class TDTestCase:
break
return buildPath
def _async_raise(self, tid, exctype):
"""raises the exception, performs cleanup if needed"""
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed")
def stop_thread(self,thread):
self._async_raise(thread.ident, SystemExit)
def insert_data(self,countstart,countstop):
# fisrt add data : db\stable\childtable\general table
......@@ -345,7 +329,7 @@ class TDTestCase:
threads.join()
else:
print("456")
self._is_stopped = True
self.stop_thread(threads)
assert 1 == 2 ,"some dnode started failed"
return False
# self.check3mnode()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册