[TIP] Better debugging of ResourceWarnings

Barry Warsaw barry at python.org
Thu Jun 13 12:25:49 PDT 2013


I'm wondering if anybody has some advice for tracking down ResourceWarnings in
a test suite of some code written for Python 3.3.

I've got a few of these cropping up which are probably related to ssl sockets
that aren't getting closed properly, but it's been difficult for me to track
them down by code inspection alone.  Even when I instrument my tox.ini file to
run the tests with -Werror::ResourceWarning, I don't get much more output than
this:

test_load_index_with_device_keyring (resolver.tests.test_index.TestDownloadIndex) ... Exception ResourceWarning: ResourceWarning('unclosed <ssl.SSLSocket object, fd=5, family=2, type=1, proto=6>',) in <ssl.SSLSocket object, fd=5, family=2, type=1, proto=6> ignored

I suspect that the warning isn't directly tied to this test though because it
can occur in different places.  It's probably due to something run by my
ThreadPoolExecutor and could be caused by a mock.

Just wondering if anybody has some general recommendations for getting better
error reporting out of Python for these types of ResourceWarnings.

Cheers,
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20130613/f6d1ed90/attachment.pgp>


More information about the testing-in-python mailing list