mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-10-12 09:10:45 +00:00
Close session when spotipy is unloaded, fixes #90
This commit is contained in:
1 parent
73aac90bbe
commit
6d7fe6c195
2 files changed
+9
No files matched your search
@@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- backoff_factor
|
- backoff_factor
|
||||||
- Spin up a local webserver to auto-fill authentication URL
|
- Spin up a local webserver to auto-fill authentication URL
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Close session when Spotipy object is unloaded
|
||||||
|
|
||||||
## [2.10.0] - 2020-03-18
|
## [2.10.0] - 2020-03-18
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -148,6 +148,11 @@ class Spotify(object):
|
|||||||
self._session.mount('http://', adapter)
|
self._session.mount('http://', adapter)
|
||||||
self._session.mount('https://', adapter)
|
self._session.mount('https://', adapter)
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
"""Make sure the connection (pool) gets closed"""
|
||||||
|
if isinstance(self._session, requests.Session):
|
||||||
|
self._session.close()
|
||||||
|
|
||||||
def _auth_headers(self):
|
def _auth_headers(self):
|
||||||
if self._auth:
|
if self._auth:
|
||||||
return {"Authorization": "Bearer {0}".format(self._auth)}
|
return {"Authorization": "Bearer {0}".format(self._auth)}
|
||||||
|
|||||||
Reference in new issue
Block a user