Skip to content

Commit a5db002

Browse files
committed
Fix issue with closing session (#200)
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`.
1 parent 59b15ae commit a5db002

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

librespot/crypto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def receive_encoded(self, connection: Session.ConnectionHolder) -> Packet:
6565
if mac != expected_mac:
6666
raise RuntimeError()
6767
return Packet(cmd, payload_bytes)
68-
except IndexError:
68+
except (IndexError, OSError):
6969
raise RuntimeError("Failed to receive packet")
7070

7171

0 commit comments

Comments
 (0)