当前位置: 首页>>代码示例>>Python>>正文


Python faulthandler.disable方法代码示例

本文整理汇总了Python中faulthandler.disable方法的典型用法代码示例。如果您正苦于以下问题:Python faulthandler.disable方法的具体用法?Python faulthandler.disable怎么用?Python faulthandler.disable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在faulthandler的用法示例。


在下文中一共展示了faulthandler.disable方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: destroy_crashlogfile

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def destroy_crashlogfile(self):
        """Clean up the crash log file and delete it."""
        if self._crash_log_file is None:
            return
        # We use sys.__stderr__ instead of sys.stderr here so this will still
        # work when sys.stderr got replaced, e.g. by "Python Tools for Visual
        # Studio".
        if sys.__stderr__ is not None:
            faulthandler.enable(sys.__stderr__)
        else:
            faulthandler.disable()  # type: ignore[unreachable]
        try:
            self._crash_log_file.close()
            os.remove(self._crash_log_file.name)
        except OSError:
            log.destroy.exception("Could not remove crash log!") 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:18,代码来源:crashsignal.py

示例2: enableFaulthandler

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def enableFaulthandler():
    """ Enable faulthandler for all threads. 
    
    If the faulthandler package is available, this function disables and then 
    re-enables fault handling for all threads (this is necessary to ensure any
    new threads are handled correctly), and returns True.

    If faulthandler is not available, then returns False.
    """
    try:
        import faulthandler
        # necessary to disable first or else new threads may not be handled.
        faulthandler.disable()
        faulthandler.enable(all_threads=True)
        return True
    except ImportError:
        return False 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:19,代码来源:debug.py

示例3: test_is_enabled

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def test_is_enabled(self):
        orig_stderr = sys.stderr
        try:
            # regrtest may replace sys.stderr by io.StringIO object, but
            # faulthandler.enable() requires that sys.stderr has a fileno()
            # method
            sys.stderr = sys.__stderr__

            was_enabled = faulthandler.is_enabled()
            try:
                faulthandler.enable()
                self.assertTrue(faulthandler.is_enabled())
                faulthandler.disable()
                self.assertFalse(faulthandler.is_enabled())
            finally:
                if was_enabled:
                    faulthandler.enable()
                else:
                    faulthandler.disable()
        finally:
            sys.stderr = orig_stderr 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:test_faulthandler.py

示例4: vdebug

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def vdebug(self: logging.Logger,
           msg: str,
           *args: typing.Any,
           **kwargs: typing.Any) -> None:
    """Log with a VDEBUG level.

    VDEBUG is used when a debug message is rather verbose, and probably of
    little use to the end user or for post-mortem debugging, i.e. the content
    probably won't change unless the code changes.
    """
    if self.isEnabledFor(VDEBUG_LEVEL):
        # pylint: disable=protected-access
        self._log(VDEBUG_LEVEL, msg, args, **kwargs)
        # pylint: enable=protected-access 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:16,代码来源:log.py

示例5: init_log

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def init_log(args: argparse.Namespace) -> None:
    """Init loggers based on the argparse namespace passed."""
    level = (args.loglevel or "info").upper()
    try:
        numeric_level = getattr(logging, level)
    except AttributeError:
        raise ValueError("Invalid log level: {}".format(args.loglevel))

    if numeric_level > logging.DEBUG and args.debug:
        numeric_level = logging.DEBUG

    console, ram = _init_handlers(numeric_level, args.color, args.force_color,
                                  args.json_logging, args.loglines)
    root = logging.getLogger()
    global console_filter
    if console is not None:
        console_filter = LogFilter.parse(args.logfilter)
        console.addFilter(console_filter)
        root.addHandler(console)
    if ram is not None:
        root.addHandler(ram)
    else:
        # If we add no handler, we shouldn't process non visible logs at all
        #
        # disable blocks the current level (while setHandler shows the current
        # level), so -1 to avoid blocking handled messages.
        logging.disable(numeric_level - 1)

    global _log_inited, _args
    _args = args
    root.setLevel(logging.NOTSET)
    logging.captureWarnings(True)
    _init_py_warnings()
    QtCore.qInstallMessageHandler(qt_message_handler)
    _log_inited = True 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:37,代码来源:log.py

示例6: ignore_py_warnings

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def ignore_py_warnings(**kwargs: typing.Any) -> typing.Iterator[None]:
    """Contextmanager to temporarily disable certain Python warnings."""
    warnings.filterwarnings('ignore', **kwargs)
    yield
    if _log_inited:
        _init_py_warnings() 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:8,代码来源:log.py

示例7: activate

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def activate(self):
        """Set up signal handlers.

        On Windows this uses a QTimer to periodically hand control over to
        Python so it can handle signals.

        On Unix, it uses a QSocketNotifier with os.set_wakeup_fd to get
        notified.
        """
        self._orig_handlers[signal.SIGINT] = signal.signal(
            signal.SIGINT, self.interrupt)
        self._orig_handlers[signal.SIGTERM] = signal.signal(
            signal.SIGTERM, self.interrupt)

        if utils.is_posix and hasattr(signal, 'set_wakeup_fd'):
            # pylint: disable=import-error,no-member,useless-suppression
            import fcntl
            read_fd, write_fd = os.pipe()
            for fd in [read_fd, write_fd]:
                flags = fcntl.fcntl(fd, fcntl.F_GETFL)
                fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
            self._notifier = QSocketNotifier(typing.cast(sip.voidptr, read_fd),
                                             QSocketNotifier.Read,
                                             self)
            self._notifier.activated.connect(  # type: ignore[attr-defined]
                self.handle_signal_wakeup)
            self._orig_wakeup_fd = signal.set_wakeup_fd(write_fd)
            # pylint: enable=import-error,no-member,useless-suppression
        else:
            self._timer.start(1000)
            self._timer.timeout.connect(lambda: None)
        self._activated = True 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:34,代码来源:crashsignal.py

示例8: __call__

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def __call__(self, msg=None):
        """Register or print a new message with timing information.
        """
        if self.disable:
            return
        if msg is None:
            msg = str(self._markCount)
        self._markCount += 1
        newTime = ptime.time()
        self._newMsg("  %s: %0.4f ms", 
                     msg, (newTime - self._lastTime) * 1000)
        self._lastTime = newTime 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:14,代码来源:debug.py

示例9: finish

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def finish(self, msg=None):
        """Add a final message; flush the message list if no parent profiler.
        """
        if self._finished or self.disable:
            return        
        self._finished = True
        if msg is not None:
            self(msg)
        self._newMsg("< Exiting %s, total time: %0.4f ms", 
                     self._name, (ptime.time() - self._firstTime) * 1000)
        type(self)._depth -= 1
        if self._depth < 1:
            self.flush() 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:15,代码来源:debug.py

示例10: pytest_unconfigure

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def pytest_unconfigure(config):
    import faulthandler

    faulthandler.disable()
    # close our dup file installed during pytest_configure
    f = getattr(config, "fault_handler_stderr", None)
    if f is not None:
        # re-enable the faulthandler, attaching it to the default sys.stderr
        # so we can see crashes after pytest has finished, usually during
        # garbage collection during interpreter shutdown
        config.fault_handler_stderr.close()
        del config.fault_handler_stderr
        faulthandler.enable(file=_get_stderr_fileno()) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:15,代码来源:faulthandler.py

示例11: pytest_unconfigure

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def pytest_unconfigure(self, config: Config) -> None:
        import faulthandler

        faulthandler.disable()
        # close our dup file installed during pytest_configure
        # re-enable the faulthandler, attaching it to the default sys.stderr
        # so we can see crashes after pytest has finished, usually during
        # garbage collection during interpreter shutdown
        config._store[fault_handler_stderr_key].close()
        del config._store[fault_handler_stderr_key]
        faulthandler.enable(file=self._get_stderr_fileno()) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:13,代码来源:faulthandler.py

示例12: test_disable

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def test_disable(self):
        code = """
            import faulthandler
            faulthandler.enable()
            faulthandler.disable()
            faulthandler._sigsegv()
            """
        not_expected = 'Fatal Python error'
        stderr, exitcode = self.get_output(code)
        stderr = '\n'.join(stderr)
        self.assertTrue(not_expected not in stderr,
                     "%r is present in %r" % (not_expected, stderr))
        self.assertNotEqual(exitcode, 0) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:15,代码来源:test_faulthandler.py

示例13: _crash

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import disable [as 别名]
def _crash(delay=None):
    """Induces a segfault."""
    if delay:
        time.sleep(delay)
    import faulthandler
    faulthandler.disable()
    faulthandler._sigsegv() 
开发者ID:bkerler,项目名称:android_universal,代码行数:9,代码来源:test_concurrent_futures.py


注:本文中的faulthandler.disable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。