Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
Silently abort libspotify calls after global lock is freed
Browse files Browse the repository at this point in the history
Fixes #202
  • Loading branch information
jodal committed Dec 10, 2019
1 parent a31778e commit 298226a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/changelog.rst
Expand Up @@ -2,10 +2,20 @@
Changelog
*********

v2.1.2 (UNRELEASED)
===================

Maintenance release.

- Silently abort libspotify `sp_*_release()` function calls that happen during
process shutdown, after pyspotify's global lock is freed. (Fixes:
:issue:`202`)


v2.1.1 (2019-11-17)
===================

Maintanance release.
Maintenance release.

- Add support for Python 3.8. No changes was required, but the test suite now
runs on this version too.
Expand Down
7 changes: 7 additions & 0 deletions spotify/__init__.py
Expand Up @@ -56,6 +56,13 @@ def serialized(f):

@functools.wraps(f)
def wrapper(*args, **kwargs):
if _lock is None:
# During process teardown, objects wrapped with `ffi.gc()` might be
# freed and their libspotify release functions called after the lock
# has been freed. When this happens, `_lock` will be `None`.
# Since we're already shutting down the process, we just abort the
# call when the lock is gone.
return
with _lock:
return f(*args, **kwargs)

Expand Down

0 comments on commit 298226a

Please sign in to comment.