Python atexit 模块,_exithandlers() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用atexit._exithandlers()

项目:oil    作者:oilshell    | 项目源码 | 文件源码
def setUp(self):
        s = StringIO.StringIO()
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        sys.stdout = sys.stderr = self.subst_io = s
        self.save_handlers = atexit._exithandlers
        atexit._exithandlers = []
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def tearDown(self):
        sys.stdout = self.save_stdout
        sys.stderr = self.save_stderr
        atexit._exithandlers = self.save_handlers
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def setUp(self):
        s = StringIO.StringIO()
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        sys.stdout = sys.stderr = self.subst_io = s
        self.save_handlers = atexit._exithandlers
        atexit._exithandlers = []
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def tearDown(self):
        sys.stdout = self.save_stdout
        sys.stderr = self.save_stderr
        atexit._exithandlers = self.save_handlers
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def setUp(self):
        s = StringIO.StringIO()
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        sys.stdout = sys.stderr = self.subst_io = s
        self.save_handlers = atexit._exithandlers
        atexit._exithandlers = []
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def tearDown(self):
        sys.stdout = self.save_stdout
        sys.stderr = self.save_stderr
        atexit._exithandlers = self.save_handlers
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def setUp(self):
        s = StringIO.StringIO()
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        sys.stdout = sys.stderr = self.subst_io = s
        self.save_handlers = atexit._exithandlers
        atexit._exithandlers = []
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def tearDown(self):
        sys.stdout = self.save_stdout
        sys.stderr = self.save_stderr
        atexit._exithandlers = self.save_handlers
项目:protlib    作者:EliAndrewC    | 项目源码 | 文件源码
def delete_logs():
    if hasattr(atexit, "_clear"):
        atexit._clear()
    elif hasattr(atexit, "_exithandlers"):
        atexit._exithandlers[:] = []    # stop the logging module's exit handler

    for suffix in Logger.LEVELS:
        filename = "unit_tests.{0}_log".format(suffix)
        if os.path.exists(filename):
            handlers = logging.getLogger("unit_tests." + suffix).handlers
            if handlers and handlers[0].stream:
                handlers[0].stream.close()
            os.remove(filename)