0
我正在尝试按顺序生成包含信息的日志文件。这是我有:FileIO在Python中使用子进程时不按顺序
class ExecThread(threading.Thread):
def __init__(self, command):
self.command = command
self._lock = threading.Lock()
threading.Thread.__init__ (self)
def run (self):
self._lock.acquire()
sys.stdout.write(''.join(["Executing: ",self.command,'\n']))
log_file.write(''.join([self.command,'\n']))
os.system(self.command)
self._lock.release()
for ive in locate('*.ive', root_dir):
command = "osgconv"
command = ''.join([command,' ',"-O OutputTextureFiles",' ', infile,' ', outfile,' ',"2>&1"])
conv_osg_thread = ExecThread(command)
conv_osg_thread.start()
conv_osg_thread.join()
我执行命令有这种重定向结尾:“2> & 1” 当我运行此我得到的消息之前,子进程的输出“执行嗒嗒” ,这是首先列出!我认为锁()会解决它,但不。
请帮助,我真的很感激,如果有人能指出我的错误。
啊谢谢!那很简单。 – Gareth 2010-06-14 23:48:11