File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -579,6 +579,17 @@ def __init__(self, output):
579579 self .handle = GetStdHandle (STD_ERROR_HANDLE if self .output == sys .stderr else STD_OUTPUT_HANDLE )
580580 self .matched = b''
581581
582+ def _output_write (self , data ):
583+ # Windows 10 bug since the Fall Creators Update, sometimes writing to console randomly fails
584+ # (but usually succeeds afterwards, it seems.)
585+ # Ref https://github.com/espressif/esp-idf/issues/1136
586+ for tries in range (3 ):
587+ try :
588+ self .output .write (data )
589+ return
590+ except IOError :
591+ pass
592+
582593 def write (self , data ):
583594 for b in data :
584595 l = len (self .matched )
@@ -597,18 +608,10 @@ def write(self, data):
597608 color |= FOREGROUND_INTENSITY
598609 SetConsoleTextAttribute (self .handle , color )
599610 else :
600- self .output . write (self .matched ) # not an ANSI color code, display verbatim
611+ self ._output_write (self .matched ) # not an ANSI color code, display verbatim
601612 self .matched = b''
602613 else :
603- try :
604- self .output .write (b )
605- except IOError :
606- # Windows 10 bug since the Fall Creators Update, sometimes writing to console randomly fails
607- # (but usually succeeds the second time, it seems.) Ref https://github.com/espressif/esp-idf/issues/1136
608- try :
609- self .output .write (b )
610- except IOError :
611- pass
614+ self ._output_write (b )
612615 self .matched = b''
613616
614617 def flush (self ):
You can’t perform that action at this time.
0 commit comments