Closed
Description
On a Free Threaded build, test_ssl fails with:
$ ./python -m test test_ssl --fail-env-changed -m test_ssl_in_multiple_threads
(...)
Warning -- warnings.filters was modified by test_ssl
Warning -- Before: (2199023321584, [], [])
Warning -- After: (2199997062288, [('always', None, <class 'ResourceWarning'>, None, 0)], [('always', None, <class 'ResourceWarning'>, None, 0)])
test_ssl failed (env changed)
(...)
Result: ENV CHANGED
The problem comes from test_check_hostname_idn()
which uses warnings_helper.check_no_resource_warning()
(changes warnings filters).
Activity
colesbury commentedon Nov 7, 2024
To add to your description:
check_no_resource_warning()
useswarnings.filterwarnings
andwarnings.catch_warnings
, which are not thread-safe in Python (even with the GIL).So it's not safe to run
test_check_hostname_idn
from multiple threads concurrently liketest_ssl_in_multiple_threads
is doing.vstinner commentedon Apr 2, 2025
cc @nascheme
kumaraditya303 commentedon Apr 18, 2025
Should be fixed now as warnings is thread safe now.
graingert commentedon Apr 18, 2025
It's safe (and only by default) on the free threaded builds, but not on the regular builds
pythongh-126483: disable warnings filters mutation in concurrent test…
graingert commentedon Apr 18, 2025
this also needs fixing on 3.13
gh-126483: disable warnings filters mutation in concurrent test (GH-1…
8 remaining items