From ff5df50bb70ea2b2da34ed0312f54be4cae1b594 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 17 Oct 2021 11:34:08 +0200 Subject: [PATCH] Lost patience with Kodi 19: drop use of Python multiprocessing entirely --- resources/lib/entrypoint.py | 8 +++----- resources/lib/utils.py | 31 ------------------------------- 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 128c6fef..8e3736db 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -247,12 +247,10 @@ def show_listing(xml, plex_type=None, section_id=None, synched=True, key=None): widgets.KEY = key # Process all items to show all_items = mass_api(xml) - all_items = utils.process_method_on_list(widgets.generate_item, all_items) - all_items = utils.process_method_on_list(widgets.prepare_listitem, - all_items) + all_items = [widgets.generate_item(api) for api in all_items] + all_items = [widgets.prepare_listitem(item) for item in all_items] # fill that listing... - all_items = utils.process_method_on_list(widgets.create_listitem, - all_items) + all_items = [widgets.create_listitem(item) for item in all_items] xbmcplugin.addDirectoryItems(int(sys.argv[1]), all_items, len(all_items)) # end directory listing xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED) diff --git a/resources/lib/utils.py b/resources/lib/utils.py index d7eea96a..11db93c0 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -21,17 +21,6 @@ import xml.etree.ElementTree as undefused_etree from functools import wraps import re import gc -try: - from multiprocessing.pool import ThreadPool - # Annyoing Kodi bug on Android, introduced with - # https://github.com/xbmc/xbmc/pull/20034 - # See https://github.com/croneter/PlexKodiConnect/issues/1641 - with ThreadPool(): - pass - SUPPORTS_POOL = True -except Exception: - SUPPORTS_POOL = False - import xbmc import xbmcaddon @@ -864,26 +853,6 @@ class XmlKodiSetting(object): return element -def process_method_on_list(method_to_run, items): - """ - helper method that processes a method on each item with pooling if the - system supports it - """ - all_items = [] - if SUPPORTS_POOL: - pool = ThreadPool() - with ThreadPool() as pool: - try: - all_items = pool.map(method_to_run, items) - except Exception: - # catch exception to prevent threadpool running forever - ERROR(notify=True) - else: - all_items = [method_to_run(item) for item in items] - all_items = [_f for _f in all_items if _f] - return all_items - - ############################################################################### # WRAPPERS