python-mpv-jsonipc
python-mpv-jsonipc copied to clipboard
Disconnecting...
I'm playing around and I can create a new instance of MPV or connect to an existing one just fine, but I am not sure how to disconnect once connected.
Looking at whats available, mpv.terminate()
seems to be the right thing but now and again I get,
Socket connection died.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/python_mpv_jsonipc.py", line 168, in run
current_data = self.socket.recv(1024)
OSError: [Errno 9] Bad file descriptor
How do I disconnect without an error?
That error just tells you that the socket was disconnected. If you disconnect it then it’s expected.
Thanks. But why is it inconsistent? If I run it 5 times, it might error once.
Also, shouldn't wrapping mvp.terminate()
in a try clause stop the error from being generated? It doesn't. (thought there might be something I am doing wrong given that I am new to Python)
I'm not sure why the error is inconsistent. Usually the socket will return an empty string when it is closed but it seems like sometimes for you it is giving an exception. There is already a try-catch but it prints out the exception as it is considered unexpected. (Are you on Linux or some other platform? Maybe it's a platform-specific thing.)
I am working on a Ubuntu 21.04
I am just starting to play around at the moment. My code so far is connecting to the instance and disconnecting. I wanted to confirm what I was seeing before I continue.
Thanks.