當前位置: 首頁>>代碼示例>>Python>>正文


Python faulthandler.cancel_dump_traceback_later方法代碼示例

本文整理匯總了Python中faulthandler.cancel_dump_traceback_later方法的典型用法代碼示例。如果您正苦於以下問題:Python faulthandler.cancel_dump_traceback_later方法的具體用法?Python faulthandler.cancel_dump_traceback_later怎麽用?Python faulthandler.cancel_dump_traceback_later使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在faulthandler的用法示例。


在下文中一共展示了faulthandler.cancel_dump_traceback_later方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: pytest_runtest_protocol

# 需要導入模塊: import faulthandler [as 別名]
# 或者: from faulthandler import cancel_dump_traceback_later [as 別名]
def pytest_runtest_protocol(item):
    timeout = float(item.config.getini("faulthandler_timeout") or 0.0)
    if timeout > 0:
        import faulthandler

        stderr = item.config.fault_handler_stderr
        faulthandler.dump_traceback_later(timeout, file=stderr)
        try:
            yield
        finally:
            faulthandler.cancel_dump_traceback_later()
    else:
        yield 
開發者ID:sofia-netsurv,項目名稱:python-netsurv,代碼行數:15,代碼來源:faulthandler.py

示例2: pytest_enter_pdb

# 需要導入模塊: import faulthandler [as 別名]
# 或者: from faulthandler import cancel_dump_traceback_later [as 別名]
def pytest_enter_pdb():
    """Cancel any traceback dumping due to timeout before entering pdb.
    """
    import faulthandler

    faulthandler.cancel_dump_traceback_later() 
開發者ID:sofia-netsurv,項目名稱:python-netsurv,代碼行數:8,代碼來源:faulthandler.py

示例3: pytest_exception_interact

# 需要導入模塊: import faulthandler [as 別名]
# 或者: from faulthandler import cancel_dump_traceback_later [as 別名]
def pytest_exception_interact():
    """Cancel any traceback dumping due to an interactive exception being
    raised.
    """
    import faulthandler

    faulthandler.cancel_dump_traceback_later() 
開發者ID:sofia-netsurv,項目名稱:python-netsurv,代碼行數:9,代碼來源:faulthandler.py

示例4: pytest_runtest_protocol

# 需要導入模塊: import faulthandler [as 別名]
# 或者: from faulthandler import cancel_dump_traceback_later [as 別名]
def pytest_runtest_protocol(self, item: Item) -> Generator[None, None, None]:
        timeout = self.get_timeout_config_value(item.config)
        stderr = item.config._store[fault_handler_stderr_key]
        if timeout > 0 and stderr is not None:
            import faulthandler

            faulthandler.dump_traceback_later(timeout, file=stderr)
            try:
                yield
            finally:
                faulthandler.cancel_dump_traceback_later()
        else:
            yield 
開發者ID:pytest-dev,項目名稱:pytest,代碼行數:15,代碼來源:faulthandler.py

示例5: pytest_enter_pdb

# 需要導入模塊: import faulthandler [as 別名]
# 或者: from faulthandler import cancel_dump_traceback_later [as 別名]
def pytest_enter_pdb(self) -> None:
        """Cancel any traceback dumping due to timeout before entering pdb.
        """
        import faulthandler

        faulthandler.cancel_dump_traceback_later() 
開發者ID:pytest-dev,項目名稱:pytest,代碼行數:8,代碼來源:faulthandler.py

示例6: pytest_exception_interact

# 需要導入模塊: import faulthandler [as 別名]
# 或者: from faulthandler import cancel_dump_traceback_later [as 別名]
def pytest_exception_interact(self) -> None:
        """Cancel any traceback dumping due to an interactive exception being
        raised.
        """
        import faulthandler

        faulthandler.cancel_dump_traceback_later() 
開發者ID:pytest-dev,項目名稱:pytest,代碼行數:9,代碼來源:faulthandler.py

示例7: tearDownClass

# 需要導入模塊: import faulthandler [as 別名]
# 或者: from faulthandler import cancel_dump_traceback_later [as 別名]
def tearDownClass(cls):
        cls.stop_alarm()
        signal.signal(signal.SIGALRM, cls.orig_handler)
        if hasattr(faulthandler, 'cancel_dump_traceback_later'):
            faulthandler.cancel_dump_traceback_later() 
開發者ID:ShikyoKira,項目名稱:Project-New-Reign---Nemesis-Main,代碼行數:7,代碼來源:eintr_tester.py

示例8: tearDown

# 需要導入模塊: import faulthandler [as 別名]
# 或者: from faulthandler import cancel_dump_traceback_later [as 別名]
def tearDown(self):
        self.stop_alarm()
        signal.signal(signal.SIGALRM, self.orig_handler)
        if hasattr(faulthandler, 'cancel_dump_traceback_later'):
            faulthandler.cancel_dump_traceback_later() 
開發者ID:bkerler,項目名稱:android_universal,代碼行數:7,代碼來源:eintr_tester.py

示例9: check_dump_traceback_later

# 需要導入模塊: import faulthandler [as 別名]
# 或者: from faulthandler import cancel_dump_traceback_later [as 別名]
def check_dump_traceback_later(self, repeat=False, cancel=False, loops=1,
                                   *, filename=None, fd=None):
        """
        Check how many times the traceback is written in timeout x 2.5 seconds,
        or timeout x 3.5 seconds if cancel is True: 1, 2 or 3 times depending
        on repeat and cancel options.

        Raise an error if the output doesn't match the expect format.
        """
        timeout_str = str(datetime.timedelta(seconds=TIMEOUT))
        code = """
            import faulthandler
            import time
            import sys

            timeout = {timeout}
            repeat = {repeat}
            cancel = {cancel}
            loops = {loops}
            filename = {filename!r}
            fd = {fd}

            def func(timeout, repeat, cancel, file, loops):
                for loop in range(loops):
                    faulthandler.dump_traceback_later(timeout, repeat=repeat, file=file)
                    if cancel:
                        faulthandler.cancel_dump_traceback_later()
                    time.sleep(timeout * 5)
                    faulthandler.cancel_dump_traceback_later()

            if filename:
                file = open(filename, "wb")
            elif fd is not None:
                file = sys.stderr.fileno()
            else:
                file = None
            func(timeout, repeat, cancel, file, loops)
            if filename:
                file.close()
            """
        code = code.format(
            timeout=TIMEOUT,
            repeat=repeat,
            cancel=cancel,
            loops=loops,
            filename=filename,
            fd=fd,
        )
        trace, exitcode = self.get_output(code, filename)
        trace = '\n'.join(trace)

        if not cancel:
            count = loops
            if repeat:
                count *= 2
            header = r'Timeout \(%s\)!\nThread 0x[0-9a-f]+ \(most recent call first\):\n' % timeout_str
            regex = expected_traceback(17, 26, header, min_count=count)
            self.assertRegex(trace, regex)
        else:
            self.assertEqual(trace, '')
        self.assertEqual(exitcode, 0) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:63,代碼來源:test_faulthandler.py

示例10: _check_dump_traceback_later

# 需要導入模塊: import faulthandler [as 別名]
# 或者: from faulthandler import cancel_dump_traceback_later [as 別名]
def _check_dump_traceback_later(self, repeat, cancel, filename, loops):
        """
        Check how many times the traceback is written in timeout x 2.5 seconds,
        or timeout x 3.5 seconds if cancel is True: 1, 2 or 3 times depending
        on repeat and cancel options.

        Raise an error if the output doesn't match the expect format.
        """
        timeout_str = str(datetime.timedelta(seconds=TIMEOUT))
        code = """
            import faulthandler
            import time

            def func(timeout, repeat, cancel, file, loops):
                for loop in range(loops):
                    faulthandler.dump_traceback_later(timeout, repeat=repeat, file=file)
                    if cancel:
                        faulthandler.cancel_dump_traceback_later()
                    time.sleep(timeout * 5)
                    faulthandler.cancel_dump_traceback_later()

            timeout = {timeout}
            repeat = {repeat}
            cancel = {cancel}
            loops = {loops}
            if {has_filename}:
                file = open({filename}, "wb")
            else:
                file = None
            func(timeout, repeat, cancel, file, loops)
            if file is not None:
                file.close()
            """
        code = code.format(
            timeout=TIMEOUT,
            repeat=repeat,
            cancel=cancel,
            loops=loops,
            has_filename=bool(filename),
            filename=repr(filename),
        )
        trace, exitcode = self.get_output(code, filename)
        trace = '\n'.join(trace)

        if not cancel:
            count = loops
            if repeat:
                count *= 2
            header = r'Timeout \(%s\)!\nThread 0x[0-9a-f]+ \(most recent call first\):\n' % timeout_str
            regex = expected_traceback(9, 20, header, min_count=count)
            self.assertRegex(trace, regex)
        else:
            self.assertEqual(trace, '')
        self.assertEqual(exitcode, 0) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:56,代碼來源:test_faulthandler.py


注:本文中的faulthandler.cancel_dump_traceback_later方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。