[PR #300] [MERGED] Fix issue with closing session (#200) #307

Closed
opened 2026-02-27 08:12:40 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/kokarare1212/librespot-python/pull/300
Author: @cvdub
Created: 3/31/2025
Status: Merged
Merged: 4/1/2025
Merged by: @kokarare1212

Base: mainHead: fix-close


📝 Commits (1)

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 librespot/crypto.py (+1 -1)

📄 Description

I was getting the following error after calling Session.close():

Exception in thread session-packet-receiver:
Traceback (most recent call last):
  File "librespot-python/librespot/crypto.py", line 58, in receive_encoded
    header_bytes = self.__receive_cipher.decrypt(connection.read(3))
                                                 ~~~~~~~~~~~~~~~^^^
  File "librespot-python/librespot/core.py", line 1889, in read
    return self.__socket.recv(length)
           ~~~~~~~~~~~~~~~~~~^^^^^^^^
OSError: [Errno 9] Bad file descriptor

Adding OSError to the try/except in CipherPair.receive_encoded fixes this issue, making CipherPair raise a RuntimeError instead, which is properly handled by Receiver.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/kokarare1212/librespot-python/pull/300 **Author:** [@cvdub](https://github.com/cvdub) **Created:** 3/31/2025 **Status:** ✅ Merged **Merged:** 4/1/2025 **Merged by:** [@kokarare1212](https://github.com/kokarare1212) **Base:** `main` ← **Head:** `fix-close` --- ### 📝 Commits (1) - [`a5db002`](https://github.com/kokarare1212/librespot-python/commit/a5db002f0015a4a6e70abd45e3c6ff20db593ed2) Fix issue with closing session (#200) ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `librespot/crypto.py` (+1 -1) </details> ### 📄 Description I was getting the following error after calling Session.close(): ``` Exception in thread session-packet-receiver: Traceback (most recent call last): File "librespot-python/librespot/crypto.py", line 58, in receive_encoded header_bytes = self.__receive_cipher.decrypt(connection.read(3)) ~~~~~~~~~~~~~~~^^^ File "librespot-python/librespot/core.py", line 1889, in read return self.__socket.recv(length) ~~~~~~~~~~~~~~~~~~^^^^^^^^ OSError: [Errno 9] Bad file descriptor ``` Adding `OSError` to the try/except in `CipherPair.receive_encoded` fixes this issue, making `CipherPair` raise a `RuntimeError` instead, which is properly handled by `Receiver`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 08:12:40 +03:00
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#307
No description provided.