Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FreeThreading] test_ssl fails with env_changed: warnings.filters was modified by test_ssl #126483

Open
vstinner opened this issue Nov 6, 2024 · 1 comment
Labels
tests Tests in the Lib/test dir topic-free-threading

Comments

@vstinner
Copy link
Member

vstinner commented Nov 6, 2024

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

@vstinner vstinner added tests Tests in the Lib/test dir topic-free-threading labels Nov 6, 2024
@colesbury
Copy link
Contributor

To add to your description: check_no_resource_warning() uses warnings.filterwarnings and warnings.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 like test_ssl_in_multiple_threads is doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir topic-free-threading
Projects
None yet
Development

No branches or pull requests

2 participants