EUDAT-B2HANDLE / B2HANDLE

B2Handle Python library for interaction with Handle services
https://eudat-b2handle.github.io/
Apache License 2.0
22 stars 24 forks source link

Close the requests session when the connector is deleted. #131

Closed mikedarcy closed 2 years ago

mikedarcy commented 5 years ago

I've seen the following warnings when multiple clients are instantiated and destroyed relatively quickly (e.g. in a unit test that creates and removes handles from a live server):

ResourceWarning: unclosed <ssl.SSLSocket fd=1092, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('xxx.xxx.xxx.xxx', 65255), raddr=('xxx.xxx.xxx.xxx', 8000)>

These unclosed sockets can easily be cleaned up by calling session.close() on the requests session when the HandleSystemConnector object is deleted.