[Zope-CVS] CVS: Packages/TestScripts - autotester.py:1.7

Chris Withers chrisw@nipltd.com
Thu, 14 Mar 2002 16:18:45 -0500


Update of /cvs-repository/Packages/TestScripts
In directory cvs.zope.org:/tmp/cvs-serv7134

Modified Files:
	autotester.py 
Log Message:
Fixed deadlock problem on Windows.

=== Packages/TestScripts/autotester.py 1.6 => 1.7 ===
 from xml2dict import xml2dict
 from StringIO import StringIO
+from threading import Thread
+
+class NonBlockingReader(Thread):
+
+    def __init__(self,file):
+        Thread.__init__(self)
+        self.file = file
+        
+    def run(self):
+        self.result = self.file.read()
+
+    def read(self):
+        return self.result
 
 f = open(argv[1])
 config = xml2dict(f.read())
@@ -31,7 +44,13 @@
     global sandbox
     chdir(join(sandbox,location))
     (i,c,e) = popen3(python+' '+command+' '+options)
-    result = c.read()+e.read()
+    ct = NonBlockingReader(c)
+    et = NonBlockingReader(e)
+    ct.start()
+    et.start()
+    ct.join()
+    et.join()    
+    result = ct.read()+et.read()
     i.close()
     c.close()
     e.close()