def enable_tty_echo(tty=None):
    """
    Re-enables proper console behavior, primarily for when a reload is
    triggered at a PDB prompt.

    TODO: context manager for ignoring signals
    """
    if tty is None:
        tty = sys.stdin
    if not tty.isatty():
        return
    try:
        import termios
    except __HOLE__:
        return

    attr_list = termios.tcgetattr(tty)
    attr_list[3] |= termios.ECHO
    try:
        orig_handler = signal.getsignal(signal.SIGTTOU)
    except AttributeError:
        termios.tcsetattr(tty, termios.TCSANOW, attr_list)
    else:
        try:
            signal.signal(signal.SIGTTOU, signal.SIG_IGN)
            termios.tcsetattr(tty, termios.TCSANOW, attr_list)
        finally:
            signal.signal(signal.SIGTTOU, orig_handler)
    return
dataset/ETHPy150Open mahmoud/clastic/clastic/server.py/enable_tty_echo