Handle Lobsters comment parsing TypeErrors
Too lazy to debug this: 2023-08-29 12:56:35,111 - root - INFO - Updating lobsters story: yktkwr, index: 55 Traceback (most recent call last): File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run File "/home/tanner/qotnews/apiserver/server.py", line 194, in feed_thread valid = feed.update_story(story) File "/home/tanner/qotnews/apiserver/feed.py", line 74, in update_story res = lobsters.story(story['ref']) File "/home/tanner/qotnews/apiserver/feeds/lobsters.py", line 103, in story s['comments'] = iter_comments(r['comments']) File "/home/tanner/qotnews/apiserver/feeds/lobsters.py", line 76, in iter_comments parent_stack = parent_stack[:indent-1] TypeError: unsupported operand type(s) for -: 'NoneType' and 'int' 2023-08-29T12:56:35Z <Greenlet at 0x7f92ad840ae0: feed_thread> failed with TypeError
This commit is contained in:
parent
632d028e4c
commit
c65fb69092
|
@ -100,7 +100,13 @@ def story(ref):
|
|||
s['title'] = r.get('title', '')
|
||||
s['link'] = SITE_LINK(ref)
|
||||
s['url'] = r.get('url', '')
|
||||
s['comments'] = iter_comments(r['comments'])
|
||||
|
||||
try:
|
||||
s['comments'] = iter_comments(r['comments'])
|
||||
except TypeError:
|
||||
logging.exception('TypeError iterating lobsters comments, skipping article.')
|
||||
return False
|
||||
|
||||
s['num_comments'] = r['comment_count']
|
||||
|
||||
if 'description' in r and r['description']:
|
||||
|
|
Loading…
Reference in New Issue
Block a user