New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor client internal calls to allow keepalive #269
Refactor client internal calls to allow keepalive #269
Conversation
This merges [PR-269](spotipy-dev#269) from the base spotipy project ahead of it getting merged in upstream
This merges [PR-269](spotipy-dev#269) from the base spotipy project ahead of it getting merged in upstream.
Hey! I am hosting a new master branch for this repo since the old creator has been MIA for 2 years. Hoping to get this repo back on it's feet and in good standing. I've been working on updating tests and adding all new functionality and have merged some of the PR's that I thought were sufficient for merging. If your PR didn't make it, resubmit it please. Thanks! |
Hey @sonneveld. Great PR, thanks! Just ran the tests locally, and integration tests are twice as fast:
vs.
Going to resolve conflicts and merge it. Will open a new one to fix a warning in the tests |
TIL we are allowed to push on a fork's branch if a PR is open:
|
Nice! Just caught up on the news of the new maintainers. Good luck and thanks for taking it on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @sonneveld! Looks good to me.
This example code now consistently runs considerably faster:
playlist_url = "https://open.spotify.com/playlist/58mpINjST18mK6qvvPYRzO"
playlist = sp.playlist(playlist_url)
tracks = playlist["tracks"]
while True:
for item in tracks["items"]:
print(item["track"]["name"])
if not tracks["next"]:
break
tracks = sp.next(tracks)
Takes ~26s without this PR and ~15s with this PR.
Internal calls were closing the http connection after every request, which meant that subsequent queries had to recreate the connection. By only closing the request object, I halved the time it took to get my saved tracks:
loading saved tracks before:
real 0m39.799s
loading saved tracks after:
real 0m19.340s