Timeout when getting rss feeds

merge-requests/30/head
Bob Mottram 2022-04-24 20:03:02 +01:00
parent b8b9f9f2fc
commit aee89ca8c9
4 changed files with 16 additions and 6 deletions

View File

@ -20804,6 +20804,9 @@ def run_daemon(preferred_podcast_formats: [],
'Reminder': 'r' 'Reminder': 'r'
} }
# timeout used when getting rss feeds
httpd.rss_timeout_sec = 20
# timeout used when checking for actor changes when clicking an avatar # timeout used when checking for actor changes when clicking an avatar
# and entering person options screen # and entering person options screen
if check_actor_timeout < 2: if check_actor_timeout < 2:

View File

@ -1162,10 +1162,11 @@ if podcast_formats_str:
preferred_podcast_formats.append(pod_format) preferred_podcast_formats.append(pod_format)
if args.rss: if args.rss:
timeout_sec = 20
session = create_session(None) session = create_session(None)
testRSS = get_rss(base_dir, domain, session, args.rss, testRSS = get_rss(base_dir, domain, session, args.rss,
False, False, 1000, 1000, 1000, 1000, debug, False, False, 1000, 1000, 1000, 1000, debug,
preferred_podcast_formats) preferred_podcast_formats, timeout_sec)
pprint(testRSS) pprint(testRSS)
sys.exit() sys.exit()

View File

@ -818,7 +818,8 @@ def run_newswire_daemon(base_dir: str, httpd,
httpd.maxCategoriesFeedItemSizeKb, httpd.maxCategoriesFeedItemSizeKb,
httpd.system_language, httpd.system_language,
httpd.debug, httpd.debug,
httpd.preferred_podcast_formats) httpd.preferred_podcast_formats,
httpd.rss_timeout_sec)
if not httpd.newswire: if not httpd.newswire:
print('Newswire feeds not updated') print('Newswire feeds not updated')

View File

@ -1278,7 +1278,8 @@ def get_rss(base_dir: str, domain: str, session, url: str,
max_posts_per_source: int, max_feed_size_kb: int, max_posts_per_source: int, max_feed_size_kb: int,
max_feed_item_size_kb: int, max_feed_item_size_kb: int,
max_categories_feedItem_size_kb: int, debug: bool, max_categories_feedItem_size_kb: int, debug: bool,
preferred_podcast_formats: []) -> {}: preferred_podcast_formats: [],
timeout_sec: int) -> {}:
"""Returns an RSS url as a dict """Returns an RSS url as a dict
""" """
if not isinstance(url, str): if not isinstance(url, str):
@ -1302,7 +1303,9 @@ def get_rss(base_dir: str, domain: str, session, url: str,
url = _yt_channel_to_atom_feed(url) url = _yt_channel_to_atom_feed(url)
try: try:
result = \ result = \
session.get(url, headers=session_headers, params=session_params) session.get(url, headers=session_headers,
params=session_params,
timeout=timeout_sec)
if result: if result:
if int(len(result.text) / 1024) < max_feed_size_kb and \ if int(len(result.text) / 1024) < max_feed_size_kb and \
not contains_invalid_chars(result.text): not contains_invalid_chars(result.text):
@ -1558,7 +1561,8 @@ def get_dict_from_newswire(session, base_dir: str, domain: str,
max_newswire_posts: int, max_newswire_posts: int,
max_categories_feedItem_size_kb: int, max_categories_feedItem_size_kb: int,
system_language: str, debug: bool, system_language: str, debug: bool,
preferred_podcast_formats: []) -> {}: preferred_podcast_formats: [],
timeout_sec: int) -> {}:
"""Gets rss feeds as a dictionary from newswire file """Gets rss feeds as a dictionary from newswire file
""" """
subscriptions_filename = base_dir + '/accounts/newswire.txt' subscriptions_filename = base_dir + '/accounts/newswire.txt'
@ -1600,7 +1604,8 @@ def get_dict_from_newswire(session, base_dir: str, domain: str,
max_posts_per_source, max_feed_size_kb, max_posts_per_source, max_feed_size_kb,
max_feed_item_size_kb, max_feed_item_size_kb,
max_categories_feedItem_size_kb, debug, max_categories_feedItem_size_kb, debug,
preferred_podcast_formats) preferred_podcast_formats,
timeout_sec)
if items_list: if items_list:
for date_str, item in items_list.items(): for date_str, item in items_list.items():
result[date_str] = item result[date_str] = item