        def _safe_write(msg):
            """
            Safe write to screen - catches IOErrors on screen resize.

            :param msg: The message to write to the screen.
            """
            try:
                sys.stdout.write(msg)
            except OSError:
                # Screen resize can throw IOErrors.  These can be safely
                # ignored as the screen will be shortly reset anyway.
                pass
Safe write to screen - catches IOErrors on screen resize.

:param msg: The message to write to the screen.
asciimatics/screen.py