我只是想在线程的帮助下并行地写两个文件。你知道吗
def dmesg (i):
cmd = 'dmesg'
print cmd
(status, cmd_out) = commands.getstatusoutput(cmd)
fil = open('dmesg_logs', 'w')
fil.write(cmd_out)
fil.close()
def dump (i):
cmd = 'lsmod'
print cmd
(status, cmd_out) = commands.getstatusoutput(cmd)
fil = open('logs', 'w')
fil.write(cmd_out)
fil.close()
if __name__ == "__main__":
t1 = threading.Thread(target = dmesg, args=(0,))
t1.start()
t2 = threading.Thread(target = dump, args=(0,))
t2.start()
while True :
"My own code"
这里我的问题是日志文件不是在线程2中创建的。我能知道我做错了什么吗?你知道吗
找到了解决办法。以上代码适用于我。你知道吗
相关问题 更多 >
编程相关推荐