Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disconnecting... #11

Open
vorgos opened this issue Sep 3, 2021 · 4 comments
Open

Disconnecting... #11

vorgos opened this issue Sep 3, 2021 · 4 comments

Comments

@vorgos
Copy link

vorgos commented Sep 3, 2021

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?

@iwalton3
Copy link
Owner

iwalton3 commented Sep 3, 2021

That error just tells you that the socket was disconnected. If you disconnect it then it’s expected.

@vorgos
Copy link
Author

vorgos commented Sep 4, 2021

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)

@iwalton3
Copy link
Owner

iwalton3 commented Sep 4, 2021

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.)

@vorgos
Copy link
Author

vorgos commented Sep 4, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants