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

Calls without timeout always return None #18

Closed
LucioSantinelli opened this issue May 8, 2017 · 6 comments
Closed

Calls without timeout always return None #18

LucioSantinelli opened this issue May 8, 2017 · 6 comments

Comments

@LucioSantinelli
Copy link

What are the attributes for server_request method?
I'm trying to do a play next/previous script in python.
Thanks for your work and support

@ismailof
Copy link
Owner

ismailof commented May 8, 2017

You don't need to directly invoke server_request. All of the methods allowed by the interface are already mimic in pyhon code. For example, asuming the client object is named mopidy you can just call:
mopidy.playback.next() or mopidy.playback.previous(). This is the preferred way since there is a little more code in between to assure the requests and responses are handled right.

@LucioSantinelli
Copy link
Author

I understand better now how this project works!
I got another question, why get_time_position, get_current_tlid() and get_state() return always None?
Thanks a lot

@LucioSantinelli
Copy link
Author

It appears like even tracklist get-methods returns always None.
Any suggestion?

@ismailof
Copy link
Owner

ismailof commented May 11, 2017

Yes, I think I know what it's going on.

Every call has a parameter timeout, which can be passed on the function. It tells how many seconds to wait for a server response. The default value is now 0, so the function does not wait for the response and returns None.

I will make a small change to the code to set the default value (if you don't specify any) to 20 seconds, so the calls work as it is. In the meantime, ¿could you set a timeout value on the calls to check that it works? Eg: get_current_tlid(timeout=20).

Another option is to use the parameter on_result=callback_function, and the answer will be passed to the callback when it's ready. This is recommended specially for time-consuming calls but not required.

Thanks for the feedback.

@ismailof ismailof changed the title How can i do a server_request? Calls without timeout always return None May 11, 2017
@ismailof
Copy link
Owner

Fixed on version 0.5.14

@LucioSantinelli
Copy link
Author

I tried to call all get-methods with timeout=20 and all works fine.
Thanks a lot.

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