Message ID | 27af0a741350371856c3493994373435cf9f4c4d.1248444364.git.mgoldish@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Jul 24, 2009 at 11:07 AM, Michael Goldish<mgoldish@redhat.com> wrote: > After launching the server the client waits for it to finish initializing. > This is done by waiting for a line of output from the server's STDOUT. > Currently, the client assumes that the first line of output coming from the > server indicates that it's done initializing. Â With Python 2.4 this used to be > true, but Python 2.6 prints deprecation warnings for certain standard modules > as soon as they are imported. Â This makes the client think the server is ready > when in fact it isn't. > > This patch fixes the problem by waiting for a certain unique output line from > the server instead of just waiting for the first line. Great! applied. > Signed-off-by: Michael Goldish <mgoldish@redhat.com> > --- > Â client/tests/kvm/kvm_subprocess.py | Â Â 5 +++-- > Â 1 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py > index 413bdaa..c15e779 100644 > --- a/client/tests/kvm/kvm_subprocess.py > +++ b/client/tests/kvm/kvm_subprocess.py > @@ -212,7 +212,8 @@ class kvm_spawn: > Â Â Â Â Â Â sub.stdin.write("%s\n" % ",".join(self.readers)) > Â Â Â Â Â Â sub.stdin.write("%s\n" % command) > Â Â Â Â Â Â # Wait for the server to complete its initialization > - Â Â Â Â Â Â sub.stdout.readline() > + Â Â Â Â Â Â while not "Server %s ready" % self.id in sub.stdout.readline(): > + Â Â Â Â Â Â Â Â pass > > Â Â Â Â # Open the reading pipes > Â Â Â Â self.reader_fds = {} > @@ -1081,7 +1082,7 @@ def _server_main(): > Â Â Â Â file.close() > > Â Â Â Â # Print something to stdout so the client can start working > - Â Â Â Â print "hello" > + Â Â Â Â print "Server %s ready" % id > Â Â Â Â sys.stdout.flush() > > Â Â Â Â # Initialize buffers > -- > 1.5.4.1 > > _______________________________________________ > Autotest mailing list > Autotest@test.kernel.org > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest >
diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py index 413bdaa..c15e779 100644 --- a/client/tests/kvm/kvm_subprocess.py +++ b/client/tests/kvm/kvm_subprocess.py @@ -212,7 +212,8 @@ class kvm_spawn: sub.stdin.write("%s\n" % ",".join(self.readers)) sub.stdin.write("%s\n" % command) # Wait for the server to complete its initialization - sub.stdout.readline() + while not "Server %s ready" % self.id in sub.stdout.readline(): + pass # Open the reading pipes self.reader_fds = {} @@ -1081,7 +1082,7 @@ def _server_main(): file.close() # Print something to stdout so the client can start working - print "hello" + print "Server %s ready" % id sys.stdout.flush() # Initialize buffers
After launching the server the client waits for it to finish initializing. This is done by waiting for a line of output from the server's STDOUT. Currently, the client assumes that the first line of output coming from the server indicates that it's done initializing. With Python 2.4 this used to be true, but Python 2.6 prints deprecation warnings for certain standard modules as soon as they are imported. This makes the client think the server is ready when in fact it isn't. This patch fixes the problem by waiting for a certain unique output line from the server instead of just waiting for the first line. Signed-off-by: Michael Goldish <mgoldish@redhat.com> --- client/tests/kvm/kvm_subprocess.py | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)