docker-py
docker-py copied to clipboard
Add context manager to the client API
ApiClient
inherence from requests.session
that implements
__enter__
and __exit__
methods and the issue #2808 asks to add the
same behaviour to the DockerClient
.
At the same time, issue #2766 reports a file descriptor leak when
_get_raw_response_socket
is called.
To fix both requests, I added a set
to the ApiClient
instance to
track every socket open by _get_raw_response_socket
and close when
the close
method is called.
I added a test, and documentation now brings the context manager as an example.
Signed-off-by: Felipe Ruhland [email protected]
This should also close #2457.