[RTEMS Project] #4091: tester: BlockingIOError: [Errno 11] write could not complete without blocking

RTEMS trac trac at rtems.org
Thu Sep 24 12:47:16 UTC 2020


#4091: tester: BlockingIOError: [Errno 11] write could not complete without
blocking
-----------------------------+---------------------
 Reporter:  Sebastian Huber  |       Owner:  (none)
     Type:  defect           |      Status:  new
 Priority:  normal           |   Milestone:  6.1
Component:  tool             |     Version:  6
 Severity:  normal           |  Resolution:
 Keywords:                   |  Blocked By:
 Blocking:                   |
-----------------------------+---------------------

Comment (by Sebastian Huber):

 It is a bit weird. The stdout suddenly changes to non-blocking.
 {{{
 #!diff
 diff --git a/rtemstoolkit/log.py b/rtemstoolkit/log.py
 index 00fdb05..65d487e 100755
 --- a/rtemstoolkit/log.py
 +++ b/rtemstoolkit/log.py
 @@ -37,6 +37,7 @@ from __future__ import print_function
  import os
  import sys
  import threading
 +import fcntl

  from rtemstoolkit import error

 @@ -135,6 +136,19 @@ def flush(log = None):
      elif default is not None:
          default.flush()

 +def get_status(fileno):
 +    fl = fcntl.fcntl(fileno, fcntl.F_GETFL)
 +    if (fl & os.O_NONBLOCK) == os.O_NONBLOCK:
 +        print(fileno, "nonblocking")
 +    else:
 +        print(fileno, "blocking")
 +
 +def check(fd, ctx):
 +    print("check", ctx, fd)
 +    fl = fcntl.fcntl(fd.fileno(), fcntl.F_GETFL)
 +    if (fl & os.O_NONBLOCK) == os.O_NONBLOCK:
 +        raise IOError
 +
  class log:
      """Log output to stdout or a file."""
      def __init__(self, streams = None, tail_size = 100):
 @@ -145,12 +159,20 @@ class log:
          if streams:
              for s in streams:
                  if s == 'stdout':
 +                    get_status(sys.stdout.fileno())
                      self.fhs[0] = sys.stdout
 +                    fcntl.fcntl(self.fhs[0], fcntl.F_SETFL, 0)
 +                    check(self.fhs[0], "init stdout")
                  elif s == 'stderr':
 +                    get_status(sys.stderr.fileno())
                      self.fhs[1] = sys.stderr
 +                    fcntl.fcntl(self.fhs[1], fcntl.F_SETFL, 0)
 +                    check(self.fhs[1], "init stderr")
                  else:
                      try:
                          self.fhs.append(open(s, 'w'))
 +                        fcntl.fcntl(self.fhs[-1], fcntl.F_SETFL, 0)
 +                        check(self.fhs[-1], "init file")
                      except IOError as ioe:
                           raise error.general("creating log file '" + s +
 \
                                               "': " + str(ioe))
 @@ -173,9 +195,11 @@ class log:
              self.tail = self.tail[-self.tail_size:]

      def has_stdout(self):
 +        check(self.fhs[0], "has_stdout")
          return self.fhs[0] is not None

      def has_stderr(self):
 +        check(self.fhs[1], "has_stderr")
          return self.fhs[1] is not None

      def output(self, text):
 @@ -190,7 +214,13 @@ class log:
          try:
              for f in range(0, len(self.fhs)):
                  if self.fhs[f] is not None:
 -                    self.fhs[f].write(out)
 +                    check(self.fhs[f], "output")
 +                    try:
 +                        self.fhs[f].write(out)
 +                    except BlockingIOError:
 +                        print("f =", f, "fhs =", self.fhs[f])
 +                        get_status(self.fhs[f].fileno())
 +                        raise
              self.flush()
          except:
              raise
 @@ -201,6 +231,7 @@ class log:
          """Flush the output."""
          for f in range(0, len(self.fhs)):
              if self.fhs[f] is not None:
 +                check(self.fhs[f], "flush")
                  self.fhs[f].flush()

  if __name__ == "__main__":
 }}}
 With this patch I get this output:
 {{{
 rtems-test --rtems-bsp=realview_pbx_a9_qemu build/arm/realview_pbx_a9_qemu
 1 blocking
 check init stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check output <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
 RTEMS Testing - Tester, 6.0.not_released
 check flush <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
 check output <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
  Command Line: /build/rtems/6/bin/rtems-test --rtems-
 bsp=realview_pbx_a9_qemu build/arm/realview_pbx_a9_qemu
  Host: Linux huber-nb-linux.suse 4.12.14-lp151.28.59-default #1 SMP Wed
 Aug 5 10:58:34 UTC 2020 (337e42e) x86_64
  Python: 3.6.10 (default, Jan 16 2020, 09:12:04) [GCC]
 check flush <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
 check output <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
 Host: Linux-4.12.14-lp151.28.59-default-x86_64-with-glibc2.3.4 (Linux
 huber-nb-linux.suse 4.12.14-lp151.28.59-default #1 SMP Wed Aug 5 10:58:34
 UTC 2020 (337e42e) x86_64 x86_64)
 check flush <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 [  2/598] p:0   f:0   u:0   e:0   I:0   B:0   t:0   L:0   i:0   W:0   |
 arm/realview_pbx_a9_qemu: linpack.exe
 [  4/598] p:0   f:0   u:0   e:0   I:0   B:0   t:0   L:0   i:0   W:0   |
 arm/realview_pbx_a9_qemu: fsbdpart01.exe
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 check has_stdout <_io.TextIOWrapper name='<stdout>' mode='w'
 encoding='UTF-8'>
 Traceback (most recent call last):
   File "/build/rtems/6/share/rtems/tester/rt/cmd-test.py", line 42, in
 <module>
     test.run(sys.argv[1:], command_path = base)
   File "/build/rtems/6/share/rtems/tester/rt/test.py", line 489, in run
     tst.reraise()
   File "/build/rtems/6/share/rtems/tester/rt/test.py", line 161, in
 reraise
     reraise.reraise(*self.result)
   File "/build/rtems/6/share/rtems/rtemstoolkit/reraise.py", line 63, in
 reraise
     raise value.with_traceback(tb)
   File "/build/rtems/6/share/rtems/tester/rt/test.py", line 143, in runner
     self.test.run()
   File "/build/rtems/6/share/rtems/tester/rt/test.py", line 115, in run
     self.config.run()
   File "/build/rtems/6/share/rtems/tester/rt/config.py", line 370, in run
     self.load(self.name)
   File "/build/rtems/6/share/rtems/rtemstoolkit/config.py", line 772, in
 load
     dir, info, data = self._process_directive(r, dir, info, data)
   File "/build/rtems/6/share/rtems/rtemstoolkit/config.py", line 638, in
 _process_directive
     directive, into, data = self._directive_filter(results, directive,
 info, data)
   File "/build/rtems/6/share/rtems/tester/rt/config.py", line 320, in
 _directive_filter
     bsp_arch, bsp, self.show_header)
   File "/build/rtems/6/share/rtems/tester/rt/report.py", line 124, in
 start
     log.notice(header, stdout_only = True)
   File "/build/rtems/6/share/rtems/rtemstoolkit/log.py", line 117, in
 notice
     (default is not None and not default.has_stdout() or stdout_only):
   File "/build/rtems/6/share/rtems/rtemstoolkit/log.py", line 199, in
 has_stdout
     check(self.fhs[0], "has_stdout")
   File "/build/rtems/6/share/rtems/rtemstoolkit/log.py", line 150, in
 check
     raise IOError
 OSError
 }}}
 So, stdout is blocking for a while and then changes to non-blocking.

--
Ticket URL: <http://devel.rtems.org/ticket/4091#comment:6>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list