我想运行两个进程子作为
#!/usr/bin/env python
from multiprocessing import Process
import time
def method(namelog):
filelog = open(namelog,'w')
while True:
time.sleep(0.1)
filelog.write('test log anything \n')
if __name__ == '__main__':
p1 = Process(target=method, args=('log1.log',))
print "start process1"
p1.start()
p2 = Process(target=method, args=('log2.log',))
print "start process2"
p2.start()
结果 :
start process1
start process2
program create 2 file log1.log and log2.log
but not save data
我创建了一个过程,但它不起作用帮助我!