All of lore.kernel.org
 help / color / mirror / Atom feed
From: Randy Witt <randy.e.witt@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 1/3] qemurunner.py: Move some class variables that should only be local
Date: Thu, 20 Aug 2015 15:24:08 -0700	[thread overview]
Message-ID: <1440109450-9173-2-git-send-email-randy.e.witt@linux.intel.com> (raw)
In-Reply-To: <1440109450-9173-1-git-send-email-randy.e.witt@linux.intel.com>

The bootlog and qemusock variables were set in the class as part of the
create_socket() routine. However those variables are never used outside
of the same function and thus serve no purpose as class variables.

This initializes those variables near where they are used.

Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com>
---
 meta/lib/oeqa/utils/qemurunner.py | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 0458447..c5bb13c 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -43,9 +43,6 @@ class QemuRunner:
 
     def create_socket(self):
 
-        self.bootlog = ''
-        self.qemusock = None
-
         try:
             self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
             self.server_socket.setblocking(0)
@@ -145,22 +142,24 @@ class QemuRunner:
             socklist = [self.server_socket]
             reachedlogin = False
             stopread = False
+            qemusock = None
+            bootlog = ''
             while time.time() < endtime and not stopread:
                 sread, swrite, serror = select.select(socklist, [], [], 5)
                 for sock in sread:
                     if sock is self.server_socket:
-                        self.qemusock, addr = self.server_socket.accept()
-                        self.qemusock.setblocking(0)
-                        socklist.append(self.qemusock)
+                        qemusock, addr = self.server_socket.accept()
+                        qemusock.setblocking(0)
+                        socklist.append(qemusock)
                         socklist.remove(self.server_socket)
                         logger.info("Connection from %s:%s" % addr)
                     else:
                         data = sock.recv(1024)
                         if data:
                             self.log(data)
-                            self.bootlog += data
-                            if re.search(".* login:", self.bootlog):
-                                self.server_socket = self.qemusock
+                            bootlog += data
+                            if re.search(".* login:", bootlog):
+                                self.server_socket = qemusock
                                 stopread = True
                                 reachedlogin = True
                                 logger.info("Reached login banner")
@@ -171,7 +170,7 @@ class QemuRunner:
 
             if not reachedlogin:
                 logger.info("Target didn't reached login boot in %d seconds" % self.boottime)
-                lines = "\n".join(self.bootlog.splitlines()[-25:])
+                lines = "\n".join(bootlog.splitlines()[-25:])
                 logger.info("Last 25 lines of text:\n%s" % lines)
                 logger.info("Check full boot log: %s" % self.logfile)
                 self.stop()
-- 
2.4.3



  reply	other threads:[~2015-08-20 22:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-20 22:24 Try to fix qemu freezing due to full socket buffers Randy Witt
2015-08-20 22:24 ` Randy Witt [this message]
2015-08-20 22:24 ` [PATCH 2/3] qemurunner: Make create_socket() return data and use exceptions Randy Witt
2015-08-20 22:24 ` [PATCH 3/3] qemurunner: Use two serial ports and log console with a thread Randy Witt
2015-08-20 23:46 ` [PATCH V2 0/3] Try to fix qemu freezing due to full socket buffers Randy Witt
2015-08-20 23:46   ` [PATCH V2 1/3] qemurunner.py: Move some class variables that should only be local Randy Witt
2015-08-20 23:46   ` [PATCH V2 2/3] qemurunner: Make create_socket() return data and use exceptions Randy Witt
2015-08-20 23:46   ` [PATCH V2 3/3] qemurunner: Use two serial ports and log console with a thread Randy Witt
2015-08-21 13:36 ` Try to fix qemu freezing due to full socket buffers Burton, Ross
2015-08-21 13:41   ` Richard Purdie
2015-08-21 14:23     ` Burton, Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440109450-9173-2-git-send-email-randy.e.witt@linux.intel.com \
    --to=randy.e.witt@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.