$67 GRAYBYTE WORDPRESS FILE MANAGER $72

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.162.162 | ADMIN IP 216.73.217.149
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/cloudlinux/venv/lib/python3.11/site-packages/_pytest/

HOME
Current File : /opt/cloudlinux/venv/lib/python3.11/site-packages/_pytest//faulthandler.py
import io
import os
import sys
from typing import Generator

import pytest
from _pytest.config import Config
from _pytest.config.argparsing import Parser
from _pytest.nodes import Item
from _pytest.stash import StashKey


fault_handler_stderr_fd_key = StashKey[int]()
fault_handler_originally_enabled_key = StashKey[bool]()


def pytest_addoption(parser: Parser) -> None:
    help = (
        "Dump the traceback of all threads if a test takes "
        "more than TIMEOUT seconds to finish"
    )
    parser.addini("faulthandler_timeout", help, default=0.0)


def pytest_configure(config: Config) -> None:
    import faulthandler

    config.stash[fault_handler_stderr_fd_key] = os.dup(get_stderr_fileno())
    config.stash[fault_handler_originally_enabled_key] = faulthandler.is_enabled()
    faulthandler.enable(file=config.stash[fault_handler_stderr_fd_key])


def pytest_unconfigure(config: Config) -> None:
    import faulthandler

    faulthandler.disable()
    # Close the dup file installed during pytest_configure.
    if fault_handler_stderr_fd_key in config.stash:
        os.close(config.stash[fault_handler_stderr_fd_key])
        del config.stash[fault_handler_stderr_fd_key]
    if config.stash.get(fault_handler_originally_enabled_key, False):
        # Re-enable the faulthandler if it was originally enabled.
        faulthandler.enable(file=get_stderr_fileno())


def get_stderr_fileno() -> int:
    try:
        fileno = sys.stderr.fileno()
        # The Twisted Logger will return an invalid file descriptor since it is not backed
        # by an FD. So, let's also forward this to the same code path as with pytest-xdist.
        if fileno == -1:
            raise AttributeError()
        return fileno
    except (AttributeError, io.UnsupportedOperation):
        # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
        # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
        # This is potentially dangerous, but the best we can do.
        return sys.__stderr__.fileno()


def get_timeout_config_value(config: Config) -> float:
    return float(config.getini("faulthandler_timeout") or 0.0)


@pytest.hookimpl(hookwrapper=True, trylast=True)
def pytest_runtest_protocol(item: Item) -> Generator[None, None, None]:
    timeout = get_timeout_config_value(item.config)
    if timeout > 0:
        import faulthandler

        stderr = item.config.stash[fault_handler_stderr_fd_key]
        faulthandler.dump_traceback_later(timeout, file=stderr)
        try:
            yield
        finally:
            faulthandler.cancel_dump_traceback_later()
    else:
        yield


@pytest.hookimpl(tryfirst=True)
def pytest_enter_pdb() -> None:
    """Cancel any traceback dumping due to timeout before entering pdb."""
    import faulthandler

    faulthandler.cancel_dump_traceback_later()


@pytest.hookimpl(tryfirst=True)
def pytest_exception_interact() -> None:
    """Cancel any traceback dumping due to an interactive exception being
    raised."""
    import faulthandler

    faulthandler.cancel_dump_traceback_later()


Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
9 Apr 2026 8.31 AM
root / root
0755
__pycache__
--
11 Feb 2026 9.30 AM
root / root
0755
_code
--
11 Feb 2026 9.30 AM
root / root
0755
_io
--
11 Feb 2026 9.30 AM
root / root
0755
_py
--
11 Feb 2026 9.30 AM
root / root
0755
assertion
--
11 Feb 2026 9.30 AM
root / root
0755
config
--
11 Feb 2026 9.30 AM
root / root
0755
mark
--
11 Feb 2026 9.30 AM
root / root
0755
__init__.py
0.348 KB
20 Jan 2026 1.01 PM
root / root
0644
_argcomplete.py
3.705 KB
20 Jan 2026 1.01 PM
root / root
0644
_version.py
0.156 KB
20 Jan 2026 1.01 PM
root / root
0644
cacheprovider.py
20.891 KB
20 Jan 2026 1.01 PM
root / root
0644
capture.py
33.923 KB
20 Jan 2026 1.01 PM
root / root
0644
compat.py
12.891 KB
20 Jan 2026 1.01 PM
root / root
0644
debugging.py
13.182 KB
20 Jan 2026 1.01 PM
root / root
0644
deprecated.py
5.358 KB
20 Jan 2026 1.01 PM
root / root
0644
doctest.py
25.353 KB
20 Jan 2026 1.01 PM
root / root
0644
faulthandler.py
3.041 KB
20 Jan 2026 1.01 PM
root / root
0644
fixtures.py
65.513 KB
20 Jan 2026 1.01 PM
root / root
0644
freeze_support.py
1.308 KB
20 Jan 2026 1.01 PM
root / root
0644
helpconfig.py
8.338 KB
20 Jan 2026 1.01 PM
root / root
0644
hookspec.py
31.795 KB
20 Jan 2026 1.01 PM
root / root
0644
junitxml.py
25.113 KB
20 Jan 2026 1.01 PM
root / root
0644
legacypath.py
16.532 KB
20 Jan 2026 1.01 PM
root / root
0644
logging.py
33.233 KB
20 Jan 2026 1.01 PM
root / root
0644
main.py
31.729 KB
20 Jan 2026 1.01 PM
root / root
0644
monkeypatch.py
14.509 KB
20 Jan 2026 1.01 PM
root / root
0644
nodes.py
25.937 KB
20 Jan 2026 1.01 PM
root / root
0644
nose.py
1.648 KB
20 Jan 2026 1.01 PM
root / root
0644
outcomes.py
10.016 KB
20 Jan 2026 1.01 PM
root / root
0644
pastebin.py
3.856 KB
20 Jan 2026 1.01 PM
root / root
0644
pathlib.py
25.219 KB
20 Jan 2026 1.01 PM
root / root
0644
py.typed
0 KB
20 Jan 2026 1.01 PM
root / root
0644
pytester.py
60.519 KB
20 Jan 2026 1.01 PM
root / root
0644
pytester_assertions.py
2.272 KB
20 Jan 2026 1.01 PM
root / root
0644
python.py
69.487 KB
20 Jan 2026 1.01 PM
root / root
0644
python_api.py
37.5 KB
20 Jan 2026 1.01 PM
root / root
0644
python_path.py
0.692 KB
20 Jan 2026 1.01 PM
root / root
0644
recwarn.py
10.674 KB
20 Jan 2026 1.01 PM
root / root
0644
reports.py
20.352 KB
20 Jan 2026 1.01 PM
root / root
0644
runner.py
18.015 KB
20 Jan 2026 1.01 PM
root / root
0644
scope.py
2.814 KB
20 Jan 2026 1.01 PM
root / root
0644
setuponly.py
3.185 KB
20 Jan 2026 1.01 PM
root / root
0644
setupplan.py
1.186 KB
20 Jan 2026 1.01 PM
root / root
0644
skipping.py
9.961 KB
20 Jan 2026 1.01 PM
root / root
0644
stash.py
2.983 KB
20 Jan 2026 1.01 PM
root / root
0644
stepwise.py
4.604 KB
20 Jan 2026 1.01 PM
root / root
0644
terminal.py
52.255 KB
20 Jan 2026 1.01 PM
root / root
0644
threadexception.py
2.847 KB
20 Jan 2026 1.01 PM
root / root
0644
timing.py
0.366 KB
20 Jan 2026 1.01 PM
root / root
0644
tmpdir.py
11.434 KB
20 Jan 2026 1.01 PM
root / root
0644
unittest.py
14.462 KB
20 Jan 2026 1.01 PM
root / root
0644
unraisableexception.py
3.116 KB
20 Jan 2026 1.01 PM
root / root
0644
warning_types.py
4.369 KB
20 Jan 2026 1.01 PM
root / root
0644
warnings.py
4.951 KB
20 Jan 2026 1.01 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF