Merge pull request #964 from johncheng2011/bug/inheriting-exceptions-in-init

Ignore Attribute error in Spotify.__del__
This commit is contained in:
Niko 2024-05-15 16:21:46 +02:00 committed by GitHub
commit 028539e08a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated links to Spotify in documentation
- Improve usability on README.md
- Fix `user_playlists_contents` example.
- Updated links to Spotify in documentation
- Fixed error obfuscation when Spotify class is being inherited and an error is raised in the Child's `__init__`
### Fixed
- Fixed unused description parameter in playlist creation example

View File

@ -211,8 +211,11 @@ class Spotify(object):
def __del__(self):
"""Make sure the connection (pool) gets closed"""
try:
if isinstance(self._session, requests.Session):
self._session.close()
except AttributeError:
pass
def _build_session(self):
self._session = requests.Session()