Re: [PATCH 4/4] tests: Change handling of reading non blocked empty stream for python3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019/02/08 19:41, Jouni Malinen wrote:
That looks excessive pretty ugly. Wouldn't it be simpler to just add
support for None return without separating processing based on version?

I.e., something like this (and well, I'd merge in the applicable
.decode() changes from patch 1/4 to this patch taking into account they
alone do not really fix these same read() lines):

diff --git a/tests/hwsim/vm/parallel-vm.py b/tests/hwsim/vm/parallel-vm.py
index df6c19b..d2b0def 100755
--- a/tests/hwsim/vm/parallel-vm.py
+++ b/tests/hwsim/vm/parallel-vm.py
@@ -90,7 +90,10 @@ def vm_read_stdout(vm, i):
ready = False
      try:
-        out = vm['proc'].stdout.read().decode()
+        out = vm['proc'].stdout.read()
+        if out == None:
+            return False
+        out = out.decode()
      except:
          return False
      logger.debug("VM[%d] stdout.read[%s]" % (i, out))
@@ -191,9 +194,11 @@ def show_progress(scr):
              running = True
              first_running = True
              try:
-                err = vm[i]['proc'].stderr.read().decode()
-                vm[i]['err'] += err
-                logger.debug("VM[%d] stderr.read[%s]" % (i, err))
+                err = vm[i]['proc'].stderr.read()
+                if err != None:
+                    err = err.decode()
+                    vm[i]['err'] += err
+                    logger.debug("VM[%d] stderr.read[%s]" % (i, err))
              except:
                  pass
@@ -247,8 +252,10 @@ def show_progress(scr):
              running = True
              try:
                  err = vm[i]['proc'].stderr.read()
-                vm[i]['err'] += err
-                logger.debug("VM[%d] stderr.read[%s]" % (i, err))
+                if err != None:
+                    err = err.decode()
+                    vm[i]['err'] += err
+                    logger.debug("VM[%d] stderr.read[%s]" % (i, err))
              except:
                  pass

> That looks excessive pretty ugly. Wouldn't it be simpler to just add
> support for None return without separating processing based on version?

I can understand because my previous modification is like it.

My purpose of this patch is not to catch exception if not needed.
Because catching exception makes debugging more difficult.
Indeed, sometimes I needed to comment out try statements temporarily
while doing python2 to 3 project.

Which do you like ?

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux