diff mbox

[KVM-AUTOTEST,6/6] KVM test: kvm_subprocess: use select() in read_until_output_matches()

Message ID 1254254667-19385-6-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Sept. 29, 2009, 8:04 p.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py
index 730f20e..2ac062a 100755
--- a/client/tests/kvm/kvm_subprocess.py
+++ b/client/tests/kvm/kvm_subprocess.py
@@ -848,8 +848,12 @@  class kvm_expect(kvm_tail):
         match = None
         data = ""
 
+        fd = self._get_fd("expect")
         end_time = time.time() + timeout
-        while time.time() < end_time:
+        while True:
+            r, w, x = select.select([fd], [], [],
+                                    max(0, end_time - time.time()))
+            if fd not in r: break
             # Read data from child
             newdata = self.read_nonblocking(internal_timeout)
             # Print it if necessary
@@ -868,7 +872,8 @@  class kvm_expect(kvm_tail):
                 done = True
             # Check if child has died
             if not self.is_alive():
-                logging.debug("Process terminated with status %s" % self.get_status())
+                logging.debug("Process terminated with status %s" %
+                              self.get_status())
                 done = True
             # Are we done?
             if done: break