Blob Blame History Raw
commit f68f2cf089cfd5ec45863baf59a91d5aeb0cf5c3
Author: Mike Gilbert <floppym@gentoo.org>
Date:   Sat Jun 3 14:53:51 2017 -0400

    test_vterm: handle EINTR when reading from pipe

    Fixes: https://github.com/urwid/urwid/issues/230

diff --git a/urwid/tests/test_vterm.py b/urwid/tests/test_vterm.py
index 4dadfcc..075c653 100644
--- a/urwid/tests/test_vterm.py
+++ b/urwid/tests/test_vterm.py
@@ -18,6 +18,7 @@
 #
 # Urwid web site: http://excess.org/urwid/

+import errno
 import os
 import sys
 import unittest
@@ -28,7 +29,6 @@ from urwid import vterm
 from urwid import signals
 from urwid.compat import B

-
 class DummyCommand(object):
     QUITSTRING = B('|||quit|||')

@@ -41,12 +41,20 @@ class DummyCommand(object):
         stdout.write(B('\x1bc'))

         while True:
-            data = os.read(self.reader, 1024)
+            data = self.read(1024)
             if self.QUITSTRING == data:
                 break
             stdout.write(data)
             stdout.flush()

+    def read(self, size):
+        while True:
+            try:
+                return os.read(self.reader, size)
+            except OSError as e:
+                if e.errno != errno.EINTR:
+                    raise
+
     def write(self, data):
         os.write(self.writer, data)