question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ResourceWarning: unclosed SSLSocket

See original GitHub issue

while calling self.core_api_instance.list_namespaced_pod method getting following warning message:

/usr/lib64/python3.5/json/decoder.py:355: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('<lan-ip>', 40169), raddr=('<remote-ip>', 6443)>
  obj, end = self.scan_once(s, idx)

Note:I am using unittest package in python then only above warning message is coming. Any idea reason behind it?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
tdesikancommented, Jun 1, 2021

While ignoring the ResourceWarning is one approach, a better one might be to explicitly close all the underlying connection pools that the kubernetes client uses.

Adding a __del__ function and calling rest_client.pool_manager.clear() seems to do the trick.

def __init__(self):
  self._api = client.CoreV1Api()

def __del__(self):
  self._api.api_client.rest_client.pool_manager.clear()
  self._api.api_client.close()
Read more comments on GitHub >

github_iconTop Results From Across the Web

ResourceWarning: unclosed ssl.SSLSocket #454 - boto/boto3
For some reason I'm getting a ResourceWarning about a unclosed socket, even when I'm specifically closing the socket myself.
Read more >
ResourceWarning unclosed socket in Python 3 Unit Test
Having the teardown logic in __del__ can make your program incorrect or harder to reason about, because there is no guarantee on when...
Read more >
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=4 ...
Bug 1733557 - sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr.
Read more >
Issue 43885: ResourceWarning: unclosed <ssl.SSLSocket ...
... /home/heimes/dev/python/cpython/Lib/test/support/threading_helper.py:209: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AF_INET, ...
Read more >
Am I being hacked? - Google Groups
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=1112, family=AddressFamily.AF_INET, type=SocketKind.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found