changeset 5182:5ce7455bd34b

merged moin/1.8
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 04 Oct 2009 04:12:42 +0200
parents 045d5788b82e (current diff) 76fac2e548a7 (diff)
children 4b0a3162257c
files
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/filter/__init__.py	Sun Oct 04 02:33:57 2009 +0200
+++ b/MoinMoin/filter/__init__.py	Sun Oct 04 04:12:42 2009 +0200
@@ -53,12 +53,22 @@
 
         tmax = tstart + timeout
         tnow = time.time()
-        rc = p.poll()
+        data = []
+        errors = []
+        rc = None
         while rc is None and tnow < tmax:
             time.sleep(0.001) # wait at least 1ms between polls
+            data.append(child_stdout.read())
+            errors.append(child_stderr.read())
             rc = p.poll()
             tnow = time.time()
 
+        child_stdout.close()
+        child_stderr.close()
+
+        data = ''.join(data)
+        errors = ''.join(errors)
+
         t = tnow - tstart
         if rc is None:
             logging.warning("Command '%s' timed out (%fs)" % (cmd, t))
@@ -73,10 +83,11 @@
 
     else:
         child_stdin, child_stdout, child_stderr = os.popen3(cmd)
-    data = child_stdout.read()
-    errors = child_stderr.read()
-    child_stdout.close()
-    child_stderr.close()
+        data = child_stdout.read()
+        errors = child_stderr.read()
+        child_stdout.close()
+        child_stderr.close()
+
     logging.debug("Command '%s', stderr: %s, stdout: %d bytes" % (cmd, errors, len(data)))
     return data, errors