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


Python faulthandler.enable方法代码示例

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


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

示例1: _check_modules

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [as 别名]
def _check_modules(modules):
    """Make sure the given modules are available."""
    from qutebrowser.utils import log

    for name, text in modules.items():
        try:
            # https://bitbucket.org/fdik/pypeg/commits/dd15ca462b532019c0a3be1d39b8ee2f3fa32f4e
            # pylint: disable=bad-continuation
            with log.ignore_py_warnings(
                category=DeprecationWarning,
                message=r'invalid escape sequence'
            ), log.ignore_py_warnings(
                category=ImportWarning,
                message=r'Not importing directory .*: missing __init__'
            ), log.ignore_py_warnings(
                category=DeprecationWarning,
                message=r'the imp module is deprecated',
            ):
                # pylint: enable=bad-continuation
                importlib.import_module(name)
        except ImportError as e:
            _die(text, e) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:24,代码来源:earlyinit.py

示例2: configure_pyqt

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [as 别名]
def configure_pyqt():
    """Remove the PyQt input hook and enable overflow checking.

    Doing this means we can't use the interactive shell anymore (which we don't
    anyways), but we can use pdb instead.
    """
    from PyQt5 import QtCore
    QtCore.pyqtRemoveInputHook()
    try:
        QtCore.pyqt5_enable_new_onexit_scheme(  # type: ignore[attr-defined]
            True)
    except AttributeError:
        # Added in PyQt 5.13 somewhere, going to be the default in 5.14
        pass

    from qutebrowser.qt import sip
    try:
        # Added in sip 4.19.4
        sip.enableoverflowchecking(True)  # type: ignore[attr-defined]
    except AttributeError:
        pass 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:23,代码来源:earlyinit.py

示例3: destroy_crashlogfile

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [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

示例4: enableFaulthandler

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [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

示例5: get_name

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [as 别名]
def get_name(request):
    import faulthandler
    faulthandler.enable()
    # if this is a POST request we need to process the form data
    if request.method == 'POST':
        # create a form instance and populate it with data from the request:
        form = NameForm(request.POST)
        # check whether it's valid:
        if form.is_valid():
            # process the data in form.cleaned_data as required
            # ...
            # redirect to a new URL:
            return HttpResponseRedirect('/thanks/')

    # if a GET (or any other method) we'll create a blank form
    else:
        form = NameForm(data={'your_name': 'unknown name'})

    return render(request, 'my_app/name.html', {'form': form}) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:21,代码来源:views.py

示例6: test_is_enabled

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [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

示例7: main

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [as 别名]
def main():
    faulthandler.enable()
    parser = ArgumentParser()
    subparsers = parser.add_subparsers(help='DeclaraCAD subcommands')
    viewer = subparsers.add_parser("view", help="View the given file")
    viewer.set_defaults(func=launch_viewer)
    viewer.add_argument("file", help="File to view")
    viewer.add_argument("-w", "--watch", action='store_true',
                        help="Watch for file changes and autoreload")
    viewer.add_argument("-f", "--frameless", action='store_true',
                        help="Frameless viewer")

    exporter = subparsers.add_parser("export", help="Export the given file")
    exporter.set_defaults(func=launch_exporter)
    exporter.add_argument("options", help="File to export or json string of "
                                          "ExportOption parameters")
    args = parser.parse_args()

    # Start the app
    launcher = getattr(args, 'func', launch_workbench)
    launcher(args) 
开发者ID:codelv,项目名称:declaracad,代码行数:23,代码来源:__init__.py

示例8: _run_init

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [as 别名]
def _run_init(
    argv,
    flags_parser,
):
  """Does one-time initialization and re-parses flags on rerun."""
  if _run_init.done:
    return flags_parser(argv)
  command_name.make_process_name_useful()
  # Set up absl logging handler.
  logging.use_absl_handler()
  args = _register_and_parse_flags_with_usage(
      argv=argv,
      flags_parser=flags_parser,
  )
  if faulthandler:
    try:
      faulthandler.enable()
    except Exception:  # pylint: disable=broad-except
      # Some tests verify stderr output very closely, so don't print anything.
      # Disabled faulthandler is a low-impact error.
      pass
  _run_init.done = True
  return args 
开发者ID:abseil,项目名称:abseil-py,代码行数:25,代码来源:app.py

示例9: _init_diagnostic_logging

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [as 别名]
def _init_diagnostic_logging(self) -> None:
        logFormatter = logging.Formatter("%(levelname)s: %(message)s")
        root_logger = logging.getLogger()

        log_file = os.path.join(THONNY_USER_DIR, "frontend.log")
        file_handler = logging.FileHandler(log_file, encoding="UTF-8", mode="w")
        file_handler.setFormatter(logFormatter)
        file_handler.setLevel(self._get_logging_level())
        root_logger.addHandler(file_handler)

        console_handler = logging.StreamHandler(sys.stdout)
        console_handler.setFormatter(logFormatter)
        console_handler.setLevel(self._get_logging_level())
        root_logger.addHandler(console_handler)

        root_logger.setLevel(self._get_logging_level())

        import faulthandler

        fault_out = open(os.path.join(THONNY_USER_DIR, "frontend_faults.log"), mode="w")
        faulthandler.enable(fault_out) 
开发者ID:thonny,项目名称:thonny,代码行数:23,代码来源:workbench.py

示例10: common_setup

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [as 别名]
def common_setup(enable_affinity=True, _init_logging=True):
    save_pid('controller')
    ansible_mitogen.logging.set_process_name('top')

    if _init_logging:
        ansible_mitogen.logging.setup()

    if enable_affinity:
        ansible_mitogen.affinity.policy.assign_controller()

    mitogen.utils.setup_gil()
    if faulthandler is not None:
        faulthandler.enable()

    MuxProcess.profiling = getenv_int('MITOGEN_PROFILING') > 0
    if MuxProcess.profiling:
        mitogen.core.enable_profiling()

    MuxProcess.cls_original_env = dict(os.environ)
    increase_open_file_limit() 
开发者ID:dw,项目名称:mitogen,代码行数:22,代码来源:process.py

示例11: main

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [as 别名]
def main():
    logging.basicConfig(level='DEBUG',stream=sys.stdout,format='%(asctime)s %(levelname)-8s %(name)-15s %(message)s')
    
    try:
        import faulthandler
        faulthandler.enable()
    except ImportError:
        pass
        

    with enaml.imports():
        from view import Main

    app = QtApplication()
    profiler = cProfile.Profile()
    
    view = Main()
    view.show()

    # Start the application event loop
    profiler.enable()
    app.start()
    profiler.disable()
    profiler.print_stats('tottime') 
开发者ID:frmdstryr,项目名称:enamlx,代码行数:26,代码来源:main.py

示例12: init_faulthandler

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [as 别名]
def init_faulthandler(fileobj=sys.__stderr__):
    """Enable faulthandler module if available.

    This print a nice traceback on segfaults.

    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".

    Args:
        fobj: An opened file object to write the traceback to.
    """
    if fileobj is None:
        # When run with pythonw.exe, sys.__stderr__ can be None:
        # https://docs.python.org/3/library/sys.html#sys.__stderr__
        # If we'd enable faulthandler in that case, we just get a weird
        # exception, so we don't enable faulthandler if we have no stdout.
        #
        # Later when we have our data dir available we re-enable faulthandler
        # to write to a file so we can display a crash to the user at the next
        # start.
        return
    faulthandler.enable(fileobj)
    if (hasattr(faulthandler, 'register') and hasattr(signal, 'SIGUSR1') and
            sys.stderr is not None):
        # If available, we also want a traceback on SIGUSR1.
        # pylint: disable=no-member,useless-suppression
        faulthandler.register(signal.SIGUSR1)
        # pylint: enable=no-member,useless-suppression 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:30,代码来源:earlyinit.py

示例13: activate

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [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

示例14: install_debugging_signal_handler

# 需要导入模块: import faulthandler [as 别名]
# 或者: from faulthandler import enable [as 别名]
def install_debugging_signal_handler():
    import faulthandler
    faulthandler.enable() 
开发者ID:apache,项目名称:cassandra-dtest,代码行数:5,代码来源:conftest.py

示例15: pytest_configure

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

    # avoid trying to dup sys.stderr if faulthandler is already enabled
    if faulthandler.is_enabled():
        return

    stderr_fd_copy = os.dup(_get_stderr_fileno())
    config.fault_handler_stderr = os.fdopen(stderr_fd_copy, "w")
    faulthandler.enable(file=config.fault_handler_stderr) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:12,代码来源:faulthandler.py


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