我正在尝试使用以下脚本接收kafka消息。这些消息在windows中接收,但在linux系统中未接收。同样,当在下面的代码中调用run函数时,windows中的python控制台会继续打印“在线程池内”,而linux中的python控制台只打印一次“在线程池内”,然后代码挂起(或者至少不会在控制台中给出任何信息)
def run(self):
print('Running KafkaThread. . . ')
try:
while True:
print("Inside the threadpool")
for consumer, callback in consumers:
thread_pool.submit(Handler.consumer_request, consumer, callback)
time.sleep(5)
except Exception:
logger.error(f'Error occurred in {__name__} : {sys.exc_info()[0]}', exc_info=True)
raise
def consumer_request(consumer, callback):
key, value = None, None
try:
for msg in consumer:
key = msg.key if msg.key is None else msg.key.decode('utf-8')
value = msg.value
callback.on_success(key, value)
except Exception as e:
logger.error(f'ERROR occurred while consuming from kafka {sys.exc_info()[0]}', exc_info=True)
callback.on_error(key, e)
暂无答案!
目前还没有任何答案,快来回答吧!