Android: Fix broken Python multiprocessing module (a Kodi 19.2 bug)

This commit is contained in:
croneter 2021-09-30 14:33:43 +02:00
parent 352b36d32b
commit 3d535fe2bf

View file

@ -23,6 +23,11 @@ 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
@ -867,13 +872,12 @@ def process_method_on_list(method_to_run, items):
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)
pool.close()
pool.join()
else:
all_items = [method_to_run(item) for item in items]
all_items = [_f for _f in all_items if _f]