Skip to content
Myr

Close sessions created in the functional API

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This is related to #1882 and #1685. By calling close on the session, we clear the PoolManager operated by the Session and close all sockets. Fixes #1882 Partially-fixes #1685

authored by Ian Cordasco · committed by Ian Cordasco · parent 1c52d15 · Browse files · 1 file+6 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−1 removed

  • other:+6 added−1 removed

1 file+6 added−1 removed

modified:requests/api.py+6 added-1 removed
44 unmodified lines
45 <Response [200]>46 """4748 session = sessions.Session()49 return session.request(method=method, url=url, **kwargs)49 response = session.request(method=method, url=url, **kwargs)50 # By explicitly closing the session, we avoid leaving sockets open which51 # can trigger a ResourceWarning in some cases, and look like a memory leak52 # in others.53 session.close()54 return response555657def get(url, **kwargs):58 """Sends a GET request. Returns :class:`Response` object.
73 unmodified lines