diff options
author | David Sommerseth <davids@redhat.com> | 2013-01-18 15:26:40 +0100 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2013-01-18 19:58:53 +0100 |
commit | 099134fc83af0e92d10d3a72bb4ecec2bc79d7f2 (patch) | |
tree | dacf3dec6ff35ce410f368c1922a69de48dccda1 /rteval | |
parent | 61594bcc6d2c3e954d202656217721b44f7c0419 (diff) | |
download | rteval-099134fc83af0e92d10d3a72bb4ecec2bc79d7f2.tar.gz rteval-099134fc83af0e92d10d3a72bb4ecec2bc79d7f2.tar.xz rteval-099134fc83af0e92d10d3a72bb4ecec2bc79d7f2.zip |
cyclictest: Use a tempfile buffer for cyclictest's stdout data
Using subprocess.PIPE doesn't allow cyclictest to completely exit
before the pipe is emptied. When using cyclictest with --breaktrace,
rteval will then not see that cyclictest isn't measuring and will
wait until the complete measurement duration has completed instead
of doing an earlier exit.
By using tempfile.SpooledTemporaryFile(), subprocess have a valid
file descriptor it can write the stdout data too. This makes also
cyclictest exit instantly when it needs to.
Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'rteval')
-rw-r--r-- | rteval/modules/measurement/cyclictest.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/rteval/modules/measurement/cyclictest.py b/rteval/modules/measurement/cyclictest.py index d0c7ed8..340f7ef 100644 --- a/rteval/modules/measurement/cyclictest.py +++ b/rteval/modules/measurement/cyclictest.py @@ -25,7 +25,7 @@ # are deemed to be part of the source code. # -import os, sys, subprocess, signal, libxml2, shutil +import os, sys, subprocess, signal, libxml2, shutil, tempfile, time from rteval.Log import Log from rteval.modules import rtevalModulePrototype @@ -202,6 +202,7 @@ class Cyclictest(rtevalModulePrototype): self.__cyclicdata['system'].description = ("(%d cores) " % self.__numcores) + self.__cyclicdata['0'].description self._log(Log.DEBUG, "system has %d cpu cores" % self.__numcores) self.__started = False + self.__cyclicoutput = None def __getmode(self): @@ -238,7 +239,7 @@ class Cyclictest(rtevalModulePrototype): self.__cmd = ['cyclictest', self.__interval, - '-qm', + '-qmu', '-h %d' % self.__buckets, "-p%d" % int(self.__priority), self.__getmode(), @@ -250,6 +251,9 @@ class Cyclictest(rtevalModulePrototype): if self.__cfg.has_key('breaktrace') and self.__cfg.breaktrace: self.__cmd.append("-b%d" % int(self.__cfg.breaktrace)) + # Buffer for cyclictest data written to stdout + self.__cyclicoutput = tempfile.SpooledTemporaryFile(mode='rw+b') + def _WorkloadTask(self): if self.__started: @@ -268,8 +272,9 @@ class Cyclictest(rtevalModulePrototype): fp.flush() fp.close() + self.__cyclicoutput.seek(0) self.__cyclicprocess = subprocess.Popen(self.__cmd, - stdout=subprocess.PIPE, + stdout=self.__cyclicoutput, stderr=self.__nullfp, stdin=self.__nullfp) self.__started = True @@ -283,11 +288,14 @@ class Cyclictest(rtevalModulePrototype): def _WorkloadCleanup(self): - if self.__cyclicprocess.poll() == None: + while self.__cyclicprocess.poll() == None: + self._log(Log.DEBUG, "Sending SIGINT") os.kill(self.__cyclicprocess.pid, signal.SIGINT) + time.sleep(2) # now parse the histogram output - for line in self.__cyclicprocess.stdout: + self.__cyclicoutput.seek(0) + for line in self.__cyclicoutput: if line.startswith('#'): continue vals = line.split() index = int(vals[0]) |