Merge pull request #1644 from croneter/py3-fix-multiprocessing

Android: Fix broken Python multiprocessing module (a Kodi 19.2 bug)
This commit is contained in:
croneter 2021-09-30 14:57:33 +02:00 committed by GitHub
commit d4f9dd427f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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]