Workaround for Windows 10 console bug. See
@@ -48,10 +48,20 @@ class HighlightingStream(object):
return highlighter(stream)
def write(self, text, flush=True):
- self.stream.write(console_encode(text, stream=self.stream))
+ self._write(console_encode(text, stream=self.stream))
if flush:
self.flush()
+ def _write(self, text, retry=5):
+ # Workaround for Windows 10 console bug:
+ # https://github.com/robotframework/robotframework/issues/2709
+ try:
+ self.stream.write(text)
+ except IOError as err:
+ if not (WINDOWS and err.errno == 0 and retry > 0):
+ raise
+ self._write(text, retry-1)
+
def flush(self):
self.stream.flush()
