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

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

项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def setUp(self):
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        self.stream = io.StringIO()
        sys.stdout = sys.stderr = self.stream
        atexit._clear()
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def tearDown(self):
        sys.stdout = self.save_stdout
        sys.stderr = self.save_stderr
        atexit._clear()
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_clear(self):
        a = [0]
        def inc():
            a[0] += 1

        atexit.register(inc)
        atexit._clear()
        atexit._run_exitfuncs()

        self.assertEqual(a[0], 0)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def exit():
    """Exit subprocess, possibly after first clearing exit functions.

    If config-main.cfg/.def 'General' 'delete-exitfunc' is True, then any
    functions registered with atexit will be removed before exiting.
    (VPython support)

    """
    if no_exitfunc:
        import atexit
        atexit._clear()
    sys.exit(0)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def setUp(self):
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        self.stream = io.StringIO()
        sys.stdout = sys.stderr = self.stream
        atexit._clear()
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def tearDown(self):
        sys.stdout = self.save_stdout
        sys.stderr = self.save_stderr
        atexit._clear()
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_clear(self):
        a = [0]
        def inc():
            a[0] += 1

        atexit.register(inc)
        atexit._clear()
        atexit._run_exitfuncs()

        self.assertEqual(a[0], 0)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def setUp(self):
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        self.stream = io.StringIO()
        sys.stdout = sys.stderr = self.stream
        atexit._clear()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def tearDown(self):
        sys.stdout = self.save_stdout
        sys.stderr = self.save_stderr
        atexit._clear()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_clear(self):
        a = [0]
        def inc():
            a[0] += 1

        atexit.register(inc)
        atexit._clear()
        atexit._run_exitfuncs()

        self.assertEqual(a[0], 0)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def exit():
    """Exit subprocess, possibly after first clearing exit functions.

    If config-main.cfg/.def 'General' 'delete-exitfunc' is True, then any
    functions registered with atexit will be removed before exiting.
    (VPython support)

    """
    if no_exitfunc:
        import atexit
        atexit._clear()
    capture_warnings(False)
    sys.exit(0)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def setUp(self):
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        self.stream = io.StringIO()
        sys.stdout = sys.stderr = self.stream
        atexit._clear()
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def tearDown(self):
        sys.stdout = self.save_stdout
        sys.stderr = self.save_stderr
        atexit._clear()
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_clear(self):
        a = [0]
        def inc():
            a[0] += 1

        atexit.register(inc)
        atexit._clear()
        atexit._run_exitfuncs()

        self.assertEqual(a[0], 0)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def exit():
    """Exit subprocess, possibly after first clearing exit functions.

    If config-main.cfg/.def 'General' 'delete-exitfunc' is True, then any
    functions registered with atexit will be removed before exiting.
    (VPython support)

    """
    if no_exitfunc:
        import atexit
        atexit._clear()
    capture_warnings(False)
    sys.exit(0)
项目: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)