X Tutup
Skip to content

atexit function with logging leaves broken terminal at exit #257

@ikanobori

Description

@ikanobori

I'm on an up-to-date Gentoo Linux under bash.

If, in a bpython session (no urwid), a function that does any terminal output via logging is registered to run at exit using the "atexit" module from the standard lib, then after exiting, the terminal is left in a broken state. There is no echoing of user input, and any command output is missing carriage returns (i.e. newlines only).

Comparing the output of "stty -a" in the broken vs. unbroken states, the specific settings that are altered are below (these boolean settings reflect the broken state):

  • -onclr (no newline -> newline+carriage-return translation)
  • -echo (no echoing of input)
  • parmrk (mark parity errors - probably no visible difference, but all settings should be restored, so I'm including it)

Trivial reproduce is to import a module containing the following in a bpython session and exit.

#!python

import atexit
import logging

logging.basicConfig()

def f():
    logging.critical('Aaaaahhhh!')

atexit.register(f)

As for how to prevent/fix this: I haven't the foggiest. I haven't really looked into it, but thought you terminal expert types have a better starting point. :)

P.S. I still love bpython! Thanks for your hard work!


Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup