multithreading - FileIO out of order when using subprocesses in Python -


I am trying to generate a log file with the information I have:

  Class ExecThread (threading.Thread): def __init __ (auto, command): self.command = command self._lock = threading.Lock () threading.Thread. __int_de (self) def run (self): self._lock.acquire () sys.stdout.write (''. ("Executed:", self.command, '\ n'])) log_file.write ('' ( To find '*. Ive', root_dir ([self.command, '\ n'])) os.system (self.command) self._lock.release (): command = "osgconv" (command) conv_osg_thread .start command = '' .joint ([command, '', '--O output settingsfile', '', infil, '', outfile, '', 2 'and 1;]] () Conv_osg_thread.join ()  

I'm executing the command This is the redirection in the end: "2> & 1" When I run it, I get the output of the sub-publication first message "Blow up Adit ", which is listed first! I thought lock () will fix it, but no.

Please help, I really appreciate it if someone can tell my error.

I / O is buffer by default after syys.stdout.flite () sys. Try stdout.write ().


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -