Commit c345c544 by ‘chizw’

[+]进程池优化

1 parent 5eb41f08
......@@ -73,18 +73,18 @@ def consume_kafka():
log.info(f"启动consume_kafka Thread name:{threading.current_thread().name}")
# 消费消息并进行逻辑处理
try:
process_pool = multiprocessing.Pool(processes=1, initializer=consumer_process_init)
# process_pool = multiprocessing.Pool(processes=1, initializer=consumer_process_init)
for message in consumer_new:
if message is None:
continue
log.info(f"Received message: {message}")
# 处理逻辑
# funasr_service.handle_process(str(message.value.decode('utf-8')))
arg = str(message.value.decode('utf-8'))
log.info(f"arg:{arg},process_pool1:{process_pool}")
process_pool.apply_async(func=funasr_service.handle_process, args=(arg,),
callback=consumer_process_callback,
error_callback=consumer_process_error_callback)
funasr_service.handle_process(str(message.value.decode('utf-8')))
# arg = str(message.value.decode('utf-8'))
# log.info(f"arg:{arg},process_pool1:{process_pool}")
# process_pool.apply_async(func=funasr_service.handle_process, args=(arg,),
# callback=consumer_process_callback,
# error_callback=consumer_process_error_callback)
# process = multiprocessing.Process(target=funasr_service.handle_process, args=((str(message.value.decode('utf-8'))),),)
# process.start()
print("task handle")
......
......@@ -32,4 +32,4 @@ def setup_logging(log_file):
return logger
log=setup_logging('%s/funasr.log' % "/app/soft/python_project/audio_dev/logs")
\ No newline at end of file
log=setup_logging('%s/funasr_temp.log' % "/app/soft/python_project/audio_dev/logs")
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!