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