Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
Spotify client now closes when the node disconnects.
Browse files Browse the repository at this point in the history
  • Loading branch information
JackAshwell11 committed Feb 22, 2022
1 parent d72c9ea commit a6ee74d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lavapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
__author__ = "Aspect1103"
__license__ = "MIT"
__copyright__ = "Copyright 2021-present (c) Aspect1103"
__version__ = "1.4.1"
__version__ = "1.4.2"

logging.getLogger(__name__).addHandler(logging.NullHandler())
7 changes: 7 additions & 0 deletions lavapy/ext/spotify/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,10 @@ async def _getBearerToken(self) -> None:
raise SpotifyAuthException("An error occurred while authenticating with Spotify.")
data = await response.json()
self._accessToken = data["access_token"]

async def close(self) -> None:
"""|coro|
Stops the sessions used for communicating with Spotify.
"""
await self.session.close()
3 changes: 3 additions & 0 deletions lavapy/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@ async def disconnect(self, *, force: bool = False) -> None:
for player in self.players:
await player.disconnect(force=force)

if self.spotifyClient:
await self.spotifyClient.close()

try:
await self._websocket.disconnect()
del NodePool._nodes[self.identifier]
Expand Down

0 comments on commit a6ee74d

Please sign in to comment.