$97 GRAYBYTE WORDPRESS FILE MANAGER $57

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
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//threadexception.py
import threading
import traceback
import warnings
from types import TracebackType
from typing import Any
from typing import Callable
from typing import Generator
from typing import Optional
from typing import Type

import pytest


# Copied from cpython/Lib/test/support/threading_helper.py, with modifications.
class catch_threading_exception:
    """Context manager catching threading.Thread exception using
    threading.excepthook.

    Storing exc_value using a custom hook can create a reference cycle. The
    reference cycle is broken explicitly when the context manager exits.

    Storing thread using a custom hook can resurrect it if it is set to an
    object which is being finalized. Exiting the context manager clears the
    stored object.

    Usage:
        with threading_helper.catch_threading_exception() as cm:
            # code spawning a thread which raises an exception
            ...
            # check the thread exception: use cm.args
            ...
        # cm.args attribute no longer exists at this point
        # (to break a reference cycle)
    """

    def __init__(self) -> None:
        self.args: Optional["threading.ExceptHookArgs"] = None
        self._old_hook: Optional[Callable[["threading.ExceptHookArgs"], Any]] = None

    def _hook(self, args: "threading.ExceptHookArgs") -> None:
        self.args = args

    def __enter__(self) -> "catch_threading_exception":
        self._old_hook = threading.excepthook
        threading.excepthook = self._hook
        return self

    def __exit__(
        self,
        exc_type: Optional[Type[BaseException]],
        exc_val: Optional[BaseException],
        exc_tb: Optional[TracebackType],
    ) -> None:
        assert self._old_hook is not None
        threading.excepthook = self._old_hook
        self._old_hook = None
        del self.args


def thread_exception_runtest_hook() -> Generator[None, None, None]:
    with catch_threading_exception() as cm:
        yield
        if cm.args:
            thread_name = "<unknown>" if cm.args.thread is None else cm.args.thread.name
            msg = f"Exception in thread {thread_name}\n\n"
            msg += "".join(
                traceback.format_exception(
                    cm.args.exc_type,
                    cm.args.exc_value,
                    cm.args.exc_traceback,
                )
            )
            warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))


@pytest.hookimpl(hookwrapper=True, trylast=True)
def pytest_runtest_setup() -> Generator[None, None, None]:
    yield from thread_exception_runtest_hook()


@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_call() -> Generator[None, None, None]:
    yield from thread_exception_runtest_hook()


@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_teardown() -> Generator[None, None, None]:
    yield from thread_exception_runtest_hook()

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


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

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF