[issue37322] test_ssl: test_pha_required_nocert() emits a ResourceWarning

Matthew Hughes report at bugs.python.org
Fri Jul 3 12:10:46 EDT 2020


Matthew Hughes <matthewhughes934 at gmail.com> added the comment:

I noticed this test was still emitting a "ResourceWarning":
----------------------------------------------------------------------
$ ./python -m test test_ssl -m TestPostHandshakeAuth 
0:00:00 load avg: 0.74 Run tests sequentially
0:00:00 load avg: 0.74 [1/1] test_ssl
/home/mjh/src/cpython/Lib/test/support/threading_helper.py:209: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 33451), raddr=('127.0.0.1', 34038)>
  del self.thread
ResourceWarning: Enable tracemalloc to get the object allocation traceback

== Tests result: SUCCESS ==

1 test OK.

Total duration: 1.1 sec
Tests result: SUCCESS
----------------------------------------------------------------------
and thought I would try silencing it by ensuring the SSL connection handled by the separate thread was closed before exiting. My attempt involved checking the thread's exception and acting accordingly, but I ran into a race condition which (solely as a proof of concept) I resolved by adding a sleep() call (see patch).

While I continue to search for a proper resolution I was wondering what approach someone with more insight might suggest.

----------
nosy: +mhughes
Added file: https://bugs.python.org/file49294/naive_proof_of_concept.patch

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37322>
_______________________________________


More information about the Python-bugs-list mailing list