[GH-ISSUE #77] Is it possible to save session? #6

Closed
opened 2026-02-27 08:11:24 +03:00 by kerem · 9 comments
Owner

Originally created by @staniel359 on GitHub (Sep 30, 2021).
Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/77

Hello. I wrote a script for audio fetching using your library. But the problem is each time the script is executed, each time session is created and it takes time. Is it possible to initialize session once for multiple script runs?

Originally created by @staniel359 on GitHub (Sep 30, 2021). Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/77 Hello. I wrote a script for audio fetching using your library. But the problem is each time the script is executed, each time session is created and it takes time. Is it possible to initialize session once for multiple script runs?
kerem 2026-02-27 08:11:24 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@kokarare1212 commented on GitHub (Oct 1, 2021):

Thank you for your inquiry.
Session connects to Spotify's server via a socket, which slows down the initialization process.
I don't know what kind of multiple scripts you are referring to, but you might want to use threading to share the session class and run it in multiple threads.

<!-- gh-comment-id:931809219 --> @kokarare1212 commented on GitHub (Oct 1, 2021): Thank you for your inquiry. Session connects to Spotify's server via a socket, which slows down the initialization process. I don't know what kind of multiple scripts you are referring to, but you might want to use [threading](https://docs.python.org/3/library/threading.html) to share the session class and run it in multiple threads.
Author
Owner

@kokarare1212 commented on GitHub (Oct 20, 2021):

Since there has been no response for a long time, this issue will be closed.

<!-- gh-comment-id:947608845 --> @kokarare1212 commented on GitHub (Oct 20, 2021): Since there has been no response for a long time, this issue will be closed.
Author
Owner

@staniel359 commented on GitHub (Dec 21, 2021):

@kokarare1212 Sorry for no response.
I meant that I have a script and I execute it multiple times. And each time session is created.
I wonder is it possible to initialize Session once and reuse it in each script execution?

<!-- gh-comment-id:998984608 --> @staniel359 commented on GitHub (Dec 21, 2021): @kokarare1212 Sorry for no response. I meant that I have a script and I execute it multiple times. And each time session is created. I wonder is it possible to initialize Session once and reuse it in each script execution?
Author
Owner

@kokarare1212 commented on GitHub (Dec 21, 2021):

Basically, you can't reuse the session variables since they are being processed while connected to Spotify's server,
but you may be able to create another scripts (daemon?) to pass the session variables from there.

<!-- gh-comment-id:999167864 --> @kokarare1212 commented on GitHub (Dec 21, 2021): Basically, you can't reuse the session variables since they are being processed while connected to Spotify's server, but you may be able to create another scripts (daemon?) to pass the session variables from there.
Author
Owner

@staniel359 commented on GitHub (Dec 22, 2021):

@kokarare1212 Is it possible do serialize/deserialize Session object?

<!-- gh-comment-id:999443167 --> @staniel359 commented on GitHub (Dec 22, 2021): @kokarare1212 Is it possible do serialize/deserialize `Session` object?
Author
Owner

@kokarare1212 commented on GitHub (Dec 22, 2021):

I haven't tested it, but I think you need to reconnect if you use pickle or something.

<!-- gh-comment-id:999464753 --> @kokarare1212 commented on GitHub (Dec 22, 2021): I haven't tested it, but I think you need to reconnect if you use pickle or something.
Author
Owner

@staniel359 commented on GitHub (Dec 22, 2021):

@kokarare1212 I see, thanks.

<!-- gh-comment-id:999466595 --> @staniel359 commented on GitHub (Dec 22, 2021): @kokarare1212 I see, thanks.
Author
Owner

@pdtan commented on GitHub (Aug 10, 2024):

@kokarare1212 Does session get expired? Any function to check if session is active?

<!-- gh-comment-id:2281219372 --> @pdtan commented on GitHub (Aug 10, 2024): @kokarare1212 Does session get expired? Any function to check if session is active?
Author
Owner

@kokarare1212 commented on GitHub (Aug 10, 2024):

As far as I can remember, it probably has an expiration date but has never reached it, and an exception should be thrown if it expires.

<!-- gh-comment-id:2281232364 --> @kokarare1212 commented on GitHub (Aug 10, 2024): As far as I can remember, it probably has an expiration date but has never reached it, and an exception should be thrown if it expires.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot-python-kokarare1212#6
No description provided.