swiftclient doesn't cleanup session it creates if one is not provided
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-swiftclient |
Fix Released
|
Undecided
|
Alex Schultz |
Bug Description
If a session object/http connection is not provided to the swift client, the HTTPClient defined in swiftclient.client will create a session object. This session object leaks open connections because it is not properly closed when the object is no longer needed. This leads to a ResourceWarning about an unclosed socket:
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=3, family=
Reproducer script
$ cat swift.py
#!/usr/bin/python3 -Wd
from swiftclient import client
sc = client.
print(sc)
Here is the output
$ ./swift.py
/usr/lib64/
_warnings.
/usr/lib64/
_warnings.
/usr/lib/
for l in open(os.
/usr/lib/
import imp
{'content-length': '342', 'accept-ranges': 'bytes', 'last-modified': 'Thu, 01 Aug 2019 16:23:19 GMT', 'etag': 'bf113fde97403b
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=3, family=
https:/ /review. opendev. org/#/c/ 674320/