kokarare1212/librespot-python

[Error] BrokenPipeError: [Errno 32] Broken pipe

staniel359 opened this issue · 4 comments

Hello.
I get this error sometimes:

ERROR:main:Exception on /tracks/7Emu7BfY22nsITLDtnSWIa [GET]
Traceback (most recent call last):
   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2077, in wsgi_app
     response = self.full_dispatch_request()
   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1525, in full_dispatch_request
    rv = self.handle_user_exception(e)
   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request
     rv = self.dispatch_request()
   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request
     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
   File "/root/muffon-spotify/main.py", line 44, in convert_track
     track = session.content_feeder().load(
   File "/usr/local/lib/python3.10/site-packages/librespot/audio/__init__.py", line 722, in load
     return self.load_track(playable_id, audio_quality_picker, preload,
   File "/usr/local/lib/python3.10/site-packages/librespot/audio/__init__.py", line 770, in load_track
     original = self.__session.api().get_metadata_4_track(
   File "/usr/local/lib/python3.10/site-packages/librespot/core.py", line 97, in get_metadata_4_track
     response = self.send("GET",
   File "/usr/local/lib/python3.10/site-packages/librespot/core.py", line 74, in send
     self.build_request(method, suffix, headers, body))
   File "/usr/local/lib/python3.10/site-packages/librespot/core.py", line 65, in build_request
     self.__session.tokens().get("playlist-read"))
   File "/usr/local/lib/python3.10/site-packages/librespot/core.py", line 1815, in get
     return self.get_token(scope).access_token
   File "/usr/local/lib/python3.10/site-packages/librespot/core.py", line 1830, in get_token
     response = self._session.mercury().send_sync_json(
   File "/usr/local/lib/python3.10/site-packages/librespot/mercury.py", line 183, in send_sync_json
     response = self.send_sync(request.request)
   File "/usr/local/lib/python3.10/site-packages/librespot/mercury.py", line 171, in send_sync
     seq = self.send(request, callback)
   File "/usr/local/lib/python3.10/site-packages/librespot/mercury.py", line 158, in send
     self.__session.send(cmd, buffer.read())
   File "/usr/local/lib/python3.10/site-packages/librespot/core.py", line 985, in send
     self.__send_unchecked(cmd, payload)
   File "/usr/local/lib/python3.10/site-packages/librespot/core.py", line 1060, in __send_unchecked
     self.cipher_pair.send_encoded(self.connection, cmd, payload)
   File "/usr/local/lib/python3.10/site-packages/librespot/crypto.py", line 45, in send_encoded
     connection.flush()
   File "/usr/local/lib/python3.10/site-packages/librespot/core.py", line 1522, in flush
     self.__socket.send(self.__buffer.read())
 BrokenPipeError: [Errno 32] Broken pipe

I run your app on Flask + Waitress.
The problem is solved only after server restart.

Is there a fix for this?
Thank you.

For normal use, there is no problem (the socket is disconnected internally when the process is stopped).
I'll fix it when I have time.

@kokarare1212 When will it be released?

Yes, it was released at 0.0.7.

@kokarare1212 Thank you.