This commit is contained in:
wenzhouwww@live.cn 2022-11-18 14:59:42 +08:00
parent 7602e57987
commit 9f5a406441
1 changed files with 3 additions and 4 deletions

View File

@ -2039,7 +2039,7 @@ class TdSuperTable:
conf.set("enable.auto.commit", "true")
def tmq_commit_cb_print(tmq, resp, offset, param=None):
print(f"commit: {resp}, tmq: {tmq}, offset: {offset}, param: {param}")
conf.set_auto_commit_cb(tmq_commit_cb_print, None)
# conf.set_auto_commit_cb(tmq_commit_cb_print, None)
consumer = conf.new_consumer()
topic_list = TaosTmqList()
for topic in current_topic_list:
@ -2049,13 +2049,12 @@ class TdSuperTable:
except TmqError as e :
pass
# consumer work only 30 sec
# consumer with random work life
time_start = time.time()
while 1:
res = consumer.poll(1000)
if time.time() - time_start >5 :
if time.time() - time_start >random.randint(5,50) :
break
# time.sleep(10)
try:
consumer.unsubscribe()
except TmqError as e :