code: def safe_write(buf):
      
      assert isinstance(buf, bytes)
      while True:
          try:
              os.write(1, buf)
              break
          except IOError as e:
              if e.errno != errno.EINTR:
                  raise
docs: We can get a SIGWINCH when printing, which will cause write to raise
      an EINTR. That's not a reason to stop printing.