尝试使多处理工作,但出于某种原因,它只会立即启动第一个进程。不确定我做错了什么。
cda
和cld
收集系统信息和其他日志信息。我想并行运行它们。我已经尝试过线程和处理,但是它们都立即从p1开始,从不加载其余的。
def cda():
while True:
try:
machine.collect_network_connections()
send_machine()
time.sleep(10)
except Exception as excp:
LOGGER.critical(str(excp))
time.sleep(10)
def cld(log_obj):
sender_obj = LogSender()
producer_obj = sender_obj.make_producer()
while True:
try:
sender_obj.send_log(log_obj, producer_obj)
except KeyboardInterrupt:
LOGGER.info("Exited cleanly with KeyboardInterrupt.")
sys.exit(0)
except TypeError as te:
LOGGER.error(te)
pass
time.sleep(2)
def main():
p1 = Process(target=cda())
process_list = list()
for x in config.log_list:
process_list.append(Process(target=cld(),args=(x,)))
process_list.append(p1)
for o in process_list:
o.start()