You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test_ssl: test_pha_required_nocert() emits a ResourceWarning #81503
Traceback (most recent call last):
File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_ssl.py", line 4344, in test_pha_required_nocert
s.recv(1024)
File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1226, in recvreturnself.read(buflen)
File "D:\buildarea\3.x.bolen-windows10\build\lib\ssl.py", line 1101, in readreturnself._sslobj.read(len)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
New changeset 61b1bc5 by Victor Stinner in branch 'master':
Revert "bpo-37322: Fix test_ssl.test_pha_required_nocert() ResourceWarning (GH-14662)" (GH-14669) 61b1bc5
New changeset 4c403b8 by Miss Islington (bot) in branch '3.8': bpo-37322: ssl test_pha_required_nocert() ignores expected SSLError (GH-14670) 4c403b8
matthewhughes934 commented on Jul 3, 2020
matthewhughes934mannequin
Mannequin
More actions
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.
matthewhughes934 commented on Jul 3, 2020
matthewhughes934mannequin
Mannequin
More actions
Whoops, I realise the patch I shared contained a combination of two (independent) approaches I tried:
Add sleep and perform cleanup
Naively patch catch_threading_exception to accept a cleanup routine to be run upon exiting but before removing the thread.
I wasn't aware of this bpo and created bpo-43885 a couple of days ago.
tl;dr I do not understand test changes in fb7e750 at all. I think that these changes are broken, too. ThreadedEchoServer and ConnectionHandler must not raise unhandled exceptions. An unhandled exception can break tests and sometimes causes threaded tests to hang indefinitely.
Activity
vstinner commentedon Jun 17, 2019
Ran 1 test in 0.100s
OK
== Tests result: SUCCESS ==
1 test OK.
Total duration: 1 sec 430 ms
Tests result: SUCCESS
The test fails using -Werror.
vstinner commentedon Jul 9, 2019
I marked bpo-37525 as duplicate of this issue.
vstinner commentedon Jul 9, 2019
New changeset cf9c41c by Victor Stinner in branch 'master':
bpo-37322: Fix test_ssl.test_pha_required_nocert() ResourceWarning (GH-14662)
cf9c41c
vstinner commentedon Jul 9, 2019
Oh. This test started to fail on Windows with this change. Example:
https://buildbot.python.org/all/#/builders/3/builds/3121
ERROR: test_pha_required_nocert (test.test_ssl.TestPostHandshakeAuth)
----------------------------------------------------------------------
I proposed PR 14669 to revert it.
vstinner commentedon Jul 9, 2019
New changeset 61b1bc5 by Victor Stinner in branch 'master':
Revert "bpo-37322: Fix test_ssl.test_pha_required_nocert() ResourceWarning (GH-14662)" (GH-14669)
61b1bc5
vstinner commentedon Jul 9, 2019
The test also logs an "Exception in thread Thread-2:" error:
---
Ran 1 test in 0.028s
OK
== Tests result: SUCCESS ==
1 test OK.
Total duration: 179 ms
Tests result: SUCCESS
---
Attached PR 14670 makes this log quiet.
vstinner commentedon Jul 9, 2019
New changeset 73ea546 by Victor Stinner in branch 'master':
bpo-37322: ssl test_pha_required_nocert() ignores expected SSLError (GH-14670)
73ea546
miss-islington commentedon Jul 9, 2019
New changeset 4c403b8 by Miss Islington (bot) in branch '3.8':
bpo-37322: ssl test_pha_required_nocert() ignores expected SSLError (GH-14670)
4c403b8
matthewhughes934 commentedon Jul 3, 2020
I noticed this test was still emitting a "ResourceWarning":
----------------------------------------------------------------------
== 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.
matthewhughes934 commentedon Jul 3, 2020
Whoops, I realise the patch I shared contained a combination of two (independent) approaches I tried:
tiran commentedon Apr 23, 2021
I wasn't aware of this bpo and created bpo-43885 a couple of days ago.
tl;dr I do not understand test changes in fb7e750 at all. I think that these changes are broken, too. ThreadedEchoServer and ConnectionHandler must not raise unhandled exceptions. An unhandled exception can break tests and sometimes causes threaded tests to hang indefinitely.
tiran commentedon Apr 24, 2021
New changeset c8666cf by Christian Heimes in branch 'master':
bpo-37322: Fix ResourceWarning and exception handling in test (GH-25553)
c8666cf
ambv commentedon May 2, 2021
I re-ran CI on the pull requests, the 3.8 and 3.9 failures on Windows X64 and macOS reproduced the same.
tiran commentedon May 2, 2021
I have cherry-picked e047239 into both backports and rebased them on top of upstream/3.8 and upstream/3.9.
vstinner commentedon Sep 21, 2021
ResourceWarning is no longer emitted. I close the issue.