fix race condition in ProcessLogger
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 24 Aug 2016 13:06:52 +0300
changeset 1519 f7ac0d11118e
parent 1518 a656ccb868d4
child 1520 6addc58f63a6
fix race condition in ProcessLogger
util/ProcessLogger.py
--- a/util/ProcessLogger.py	Tue Aug 23 10:24:47 2016 +0500
+++ b/util/ProcessLogger.py	Wed Aug 24 13:06:52 2016 +0300
@@ -109,6 +109,7 @@
         self.errdata = []
         self.keyword = keyword
         self.kill_it = kill_it
+        self.startsem = Semaphore(0)        
         self.finishsem = Semaphore(0)
         self.endlock = Lock()
 
@@ -145,6 +146,7 @@
                       self.Proc.stderr,
                       self.errors)
         self.errt.start()
+        self.startsem.release()
 
 
     def output(self,v):
@@ -168,6 +170,7 @@
         self.logger.write_warning(_("exited with status %s (pid %s)\n")%(str(ecode),str(pid)))
 
     def finish(self, pid,ecode):
+        self.startsem.acquire()
         if self.timeout:
             self.timeout.cancel()
         self.exitcode = ecode
@@ -179,6 +182,7 @@
         self.finishsem.release()
 
     def kill(self,gently=True):
+        self.startsem.acquire()        
         self.outt.killed = True
         self.errt.killed = True
         if wx.Platform == '__WXMSW__':