ResourceWarning: unclosed <ssl.SSLSocket fd=20, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.1.0.62', 52098), raddr=('52.239.140.10', 443)>
See original GitHub issue- azure-storage-blob:
- 12.5.0:
- Linux 39a68fd14e65 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 GNU/Linux:
- Python 3.8.3:
Describe the bug
We’ve enabled a few warning filters in our application with warning.simplefilter
and we’re seeing a python warning when we download a file from the blob storage. ResourceWarning: unclosed <ssl.SSLSocket fd=20, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.1.0.62', 52098), raddr=('52.239.140.10', 443)>
To Reproduce
client = BlobServiceClient.from_connection_string("<connection string here>").get_blob_client(container="<container name>", blob="<blob name>")
raw_data = client.download_blob().readall()
with gzip.open(BytesIO(raw_data), "rb") as fh:
data = pickle.load(fh) # noqa: S301
Expected behavior No warning or a proper way to close the stream.
Screenshots NA
Additional context NA
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
ResourceWarning unclosed socket in Python 3 Unit Test
I'm modifying some code to be compatible between Python 2 and Python 3 , but have observed a warning in unit test output....
Read more >sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=4 ...
Note - one thing that is different that the previous bug is that I'm using an IPv6 control plane, so the addresses in...
Read more >Incomprehensible warnings in log files - Tryton Discussion
From the port (389) it seems that the connection to the ldap server is not closed properly. Are you using the ldap_authentication module?...
Read more >Issue 43885: ResourceWarning: unclosed <ssl.SSLSocket ...
SSLSocket fd=5, family=AF_INET, type=SOCK_STREAM, proto=0, laddr=('127.0.0.1', 32937), raddr=('127.0.0.1', 60292)> del self.thread Object ...
Read more >Does anyone else ever get an odd warning like this when ...
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=(some address', 55332), ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @lukin0110, this is actually intended behavior. When you run
You’re creating a blob client from your BlobServiceClient and not closing any sessions. If you want to ensure all sessions are closed, you must close your parent client. You can achieve this by doing:
This ensures that the socket is closed since the child class is inheriting the same session.
You can also do:
Hope this helps! Let me know if there anything else needed
Hi @lukin0110
Thanks for reporting this issue. I was able to reproduce. The problem is we created a session and didn’t close it https://github.com/Azure/azure-sdk-for-python/blame/master/sdk/core/azure-core/azure/core/pipeline/transport/_requests_basic.py#L244
@xiangyan99 could you please find people to confirm we want to close the session before return.