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:
commit
d4f9dd427f
1 changed files with 11 additions and 7 deletions
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue