Created
July 1, 2025 19:20
-
-
Save bukzor/b8677dbe5d00abd761173c066e8f2b49 to your computer and use it in GitHub Desktop.
Fixture to catch leaked threads (DI-1008)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pytest tests/snuba/api/endpoints/test_organization_trace_meta.py::OrganizationEventsTraceMetaEndpointTest::test_bad_ids -vvvv | |
=============================== test session starts ================================ | |
platform darwin -- Python 3.13.1, pytest-8.1.2, pluggy-1.5.0 -- /Users/buck/repo/getsentry/sentry/.venv/bin/python3 | |
cachedir: .pytest_cache | |
metadata: {'Python': '3.13.1', 'Platform': 'macOS-15.5-arm64-arm-64bit-Mach-O', 'Packages': {'pytest': '8.1.2', 'pluggy': '1.5.0'}, 'Plugins': {'fail-slow': '0.3.0', 'time-machine': '2.16.0', 'json-report': '1.5.0', 'metadata': '3.1.1', 'xdist': '3.0.2', 'django': '4.9.0', 'pytest_sentry': '0.3.0', 'anyio': '3.7.1', 'rerunfailures': '15.0', 'cov': '4.0.0'}} | |
django: version: 5.2.1 | |
rootdir: /Users/buck/repo/getsentry/sentry | |
configfile: pyproject.toml | |
plugins: fail-slow-0.3.0, time-machine-2.16.0, json-report-1.5.0, metadata-3.1.1, xdist-3.0.2, django-4.9.0, pytest_sentry-0.3.0, anyio-3.7.1, rerunfailures-15.0, cov-4.0.0 | |
collected 1 item | |
tests/snuba/api/endpoints/test_organization_trace_meta.py::OrganizationEventsTraceMetaEndpointTest::test_bad_ids PASSED [100%] | |
tests/snuba/api/endpoints/test_organization_trace_meta.py::OrganizationEventsTraceMetaEndpointTest::test_bad_ids ERROR [100%] | |
====================================== ERRORS ====================================== | |
____ ERROR at teardown of OrganizationEventsTraceMetaEndpointTest.test_bad_ids _____ | |
tests/conftest.py:97: in unclosed_threads | |
_assert_same_pthreads(orig_pthreads, _get_pthreads()) | |
tests/conftest.py:79: in _assert_same_pthreads | |
assert new_diff == old_diff # both should be empty | |
E assert {pthread(id=5, user_time=0.000474, system_time=0.00022), pthread(id=6, user_time=0.000477, system_time=0.000229), pthread(id=8, user_time=0.000409, system_time=0.000149), pthread(id=7, user_time=0.000476, system_time=0.000194)} == set() | |
E | |
E Extra items in the left set: | |
E pthread(id=5, user_time=0.000474, system_time=0.00022) | |
E pthread(id=6, user_time=0.000477, system_time=0.000229) | |
E pthread(id=8, user_time=0.000409, system_time=0.000149) | |
E pthread(id=7, user_time=0.000476, system_time=0.000194) | |
E | |
E Full diff: | |
E - set() | |
E + { | |
E + pthread(id=5, user_time=0.000474, system_time=0.00022), | |
E + pthread(id=6, user_time=0.000477, system_time=0.000229), | |
E + pthread(id=7, user_time=0.000476, system_time=0.000194), | |
E + pthread(id=8, user_time=0.000409, system_time=0.000149), | |
E + } | |
The above exception was the direct cause of the following exception: | |
tests/conftest.py:102: in unclosed_threads | |
raise e2 from e1 | |
tests/conftest.py:100: in unclosed_threads | |
assert _get_python_threads() == orig_python_threads | |
E assert frozenset({<Thread(Thread-2 (worker), started daemon 6195097600)>, <Thread(_make_rpc_requests_0, started 6262403072)>, <_MainThread(MainThread, started 8745787136)>, <Thread(Thread-1 (run_server), started daemon 6178271232)>, <Thread(_make_rpc_requests_2, started 6296055808)>, <Thread(_make_rpc_requests_1, started 6279229440)>, <Thread(_make_rpc_requests_3, started 6312882176)>}) == frozenset({<Thread(Thread-2 (worker), started daemon 6195097600)>, <_MainThread(MainThread, started 8745787136)>, <Thread(Thread-1 (run_server), started daemon 6178271232)>}) | |
E | |
E Extra items in the left set: | |
E <Thread(_make_rpc_requests_2, started 6296055808)> | |
E <Thread(_make_rpc_requests_0, started 6262403072)> | |
E <Thread(_make_rpc_requests_3, started 6312882176)> | |
E <Thread(_make_rpc_requests_1, started 6279229440)> | |
E | |
E Full diff: | |
E frozenset({ | |
E <Thread(Thread-1 (run_server), started daemon 6178271232)>, | |
E <Thread(Thread-2 (worker), started daemon 6195097600)>, | |
E + <Thread(_make_rpc_requests_2, started 6296055808)>, | |
E + <Thread(_make_rpc_requests_3, started 6312882176)>, | |
E + <Thread(_make_rpc_requests_0, started 6262403072)>, | |
E + <Thread(_make_rpc_requests_1, started 6279229440)>, | |
E <_MainThread(MainThread, started 8745787136)>, | |
E }) | |
------------------------------ Captured stderr setup ------------------------------- | |
Creating test database for alias 'default' ('test_region')... | |
Creating test database for alias 'control' ('test_control')... | |
Creating test database for alias 'secondary' ('test_secondary')... | |
----------------------------- Captured stderr teardown ----------------------------- | |
Destroying test database for alias 'default' ('test_region')... | |
Destroying test database for alias 'control' ('test_control')... | |
Destroying test database for alias 'secondary' ('test_secondary')... | |
============================= short test summary info ============================== | |
ERROR tests/snuba/api/endpoints/test_organization_trace_meta.py::OrganizationEventsTraceMetaEndpointTest::test_bad_ids - assert frozenset({<Thread(Thread-2 (worker), started daemon 6195097600)>, <Thre... | |
=========================== 1 passed, 1 error in 10.37s ============================ | |
exit code: 1 | |
duration: 16.094 seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment