haikuginger / kodipydent

A complete Python client for the Kodi JSON-RPC API
MIT License
26 stars 8 forks source link

Is there a way to change the timeout? #8

Open virtadpt opened 6 years ago

virtadpt commented 6 years ago

I'm using kodipydent to write a remote control for a Kodi box with a couple of tens of thousands of MP3s in the audio library. I keep getting socket.timeout exceptions when loading the songs library:

DEBUG: Entered kodi_library.get_songs().
Traceback (most recent call last):
  File "./kodi_bot.py", line 265, in <module>
    media_library["songs"] = kodi_library.get_songs(kodi)
  File "/home/drwho/exocortex-halo/kodi_bot/kodi_library.py", line 191, in get_songs
    songs = kodi.AudioLibrary.GetSongs()
  File "/home/drwho/exocortex-halo/kodi_bot/env/lib/python2.7/site-packages/beekeeper/api.py", line 195, in execute
    _timeout=self.timeout
  File "/home/drwho/exocortex-halo/kodi_bot/env/lib/python2.7/site-packages/beekeeper/comms.py", line 97, in send
    resp = Response(self.action.format(), request(timeout=timeout, **self.output), traversal)
  File "/home/drwho/exocortex-halo/kodi_bot/env/lib/python2.7/site-packages/beekeeper/comms.py", line 64, in request
    return REQUEST_OPENER.open(req, timeout=timeout)
  File "/usr/lib64/python2.7/urllib2.py", line 429, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.7/urllib2.py", line 447, in _open
    '_open', req)
  File "/usr/lib64/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 1228, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib64/python2.7/urllib2.py", line 1201, in do_open
    r = h.getresponse(buffering=True)
  File "/usr/lib64/python2.7/httplib.py", line 1121, in getresponse
    response.begin()
  File "/usr/lib64/python2.7/httplib.py", line 438, in begin
    version, status, reason = self._read_status()
  File "/usr/lib64/python2.7/httplib.py", line 394, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "/usr/lib64/python2.7/socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
socket.timeout: timed out

The exception is popping up in Kodi.AudioLibrary.GetSongs().

Is there a way that I can change the timeout (which appears to be hardcoded in Beekeeper (https://github.com/haikuginger/beekeeper/blob/master/beekeeper/api.py#L165)) to something longer than five seconds? Is there something in the kodipydent docs that I'm missing?

virtadpt commented 6 years ago

Update: I installed Beekeeper into a virtualenv, so I went into the local copies of api.py and comms.py and changed the hardcoded timeouts to 180 seconds (after making backup copies). This solves the problem as a PoC, but it doesn't solve the problem. Would it be feasible to expose the timeout variable with kodipydent so the timeout value could be made easily configurable?

haikuginger commented 6 years ago

Hi @virtadpt! I'm looking into how we can accomplish this effectively. Hope to have results for you soon.