ismailof/mopidy-json-client

Calls without timeout always return None

Closed this issue · 6 comments

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

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.

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

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

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.

Fixed on version 0.5.14

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