[mythtv-commits] Ticket #12455: tmdb3.py crashes with status code 1
MythTV
noreply at mythtv.org
Fri Sep 11 01:35:03 UTC 2015
#12455: tmdb3.py crashes with status code 1
----------------------------------+-----------------------------
Reporter: spmorton@… | Owner:
Type: Bug Report - General | Status: new
Priority: minor | Milestone: unknown
Component: MythTV - General | Version: Unspecified
Severity: medium | Resolution:
Keywords: | Ticket locked: 0
----------------------------------+-----------------------------
Comment (by sargenthp@…):
This is what I ended up tweaking: '''/usr/lib/python2.7/dist-
packages/MythTV/tmdb3/request.py'''
[[br]][[br]]
Just under the other import lines at the top of the file I added:
{{{#!python
import time
}}}
Then I replaced this function...
{{{#!python
def readJSON(self):
"""Parse result from specified URL as JSON data."""
url = self.get_full_url()
try:
# catch HTTP error from open()
data = json.load(self.open())
except TMDBHTTPError, e:
try:
# try to load whatever was returned
data = json.loads(e.response)
except:
# cannot parse json, just raise existing error
raise e
else:
# response parsed, try to raise error from TMDB
handle_status(data, url)
# no error from TMDB, just raise existing error
raise e
handle_status(data, url)
if DEBUG:
import pprint
pprint.PrettyPrinter().pprint(data)
return data
}}}
With...
{{{#!python
def readJSON(self):
"""Parse result from specified URL as JSON data."""
url = self.get_full_url()
while True:
try:
# catch HTTP error from open()
data = json.load(self.open())
break
except TMDBHTTPError, e:
try:
# try to load whatever was returned
data = json.loads(e.response)
except:
# cannot parse json, just raise existing error
raise e
else:
# Check for error code of 25 which means we are doing
more than 40 requests per minute.
if data.get('status_code', 1) == 25:
# Sleep and retry query.
time.sleep(10)
continue
else:
# response parsed, try to raise error from TMDB
handle_status(data, url)
# no error from TMDB, just raise existing error
raise e
handle_status(data, url)
if DEBUG:
import pprint
pprint.PrettyPrinter().pprint(data)
return data
}}}
--
Ticket URL: <https://code.mythtv.org/trac/ticket/12455#comment:3>
MythTV <http://www.mythtv.org>
MythTV Media Center
More information about the mythtv-commits
mailing list