[GH-ISSUE #158] [Error] BrokenPipeError: [Errno 32] Broken pipe #25

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

Originally created by @staniel359 on GitHub (Oct 20, 2022).
Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/158

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.

Originally created by @staniel359 on GitHub (Oct 20, 2022). Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/158 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.
kerem 2026-02-27 08:11:29 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

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.

<!-- gh-comment-id:1286204296 --> @kokarare1212 commented on GitHub (Oct 20, 2022): 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.
Author
Owner

@staniel359 commented on GitHub (Nov 9, 2022):

@kokarare1212 When will it be released?

<!-- gh-comment-id:1308627188 --> @staniel359 commented on GitHub (Nov 9, 2022): @kokarare1212 When will it be released?
Author
Owner

@kokarare1212 commented on GitHub (Nov 9, 2022):

Yes, it was released at 0.0.7.

<!-- gh-comment-id:1309462752 --> @kokarare1212 commented on GitHub (Nov 9, 2022): Yes, it was released at [0.0.7](https://github.com/kokarare1212/librespot-python/releases/tag/v0.0.7).
Author
Owner

@staniel359 commented on GitHub (Nov 10, 2022):

@kokarare1212 Thank you.

<!-- gh-comment-id:1310050678 --> @staniel359 commented on GitHub (Nov 10, 2022): @kokarare1212 Thank you.
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#25
No description provided.