summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorVitiko <[email protected]>2022-03-31 23:11:32 -0400
committerVitiko <[email protected]>2022-03-31 23:11:32 -0400
commit86d6c211af8ac0b81e05937fea1973ec78bc9226 (patch)
tree0f9c8ca39915a26f1ecdfd659641d2b8e6c8d412 /libs
parent4f42cd9b2860856b3759cd438d9fdcfef5a5fdba (diff)
downloadbazarr-86d6c211af8ac0b81e05937fea1973ec78bc9226.tar.gz
bazarr-86d6c211af8ac0b81e05937fea1973ec78bc9226.zip
Fix ValueError for persistent pools on multithreaded setupsv1.0.4-beta.20
Diffstat (limited to 'libs')
-rw-r--r--libs/subliminal_patch/core.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py
index db98406c9..5e59ca895 100644
--- a/libs/subliminal_patch/core.py
+++ b/libs/subliminal_patch/core.py
@@ -548,9 +548,19 @@ class SZAsyncProviderPool(SZProviderPool):
super(SZAsyncProviderPool, self).__init__(*args, **kwargs)
#: Maximum number of threads to use
- self.max_workers = max_workers or len(self.providers)
+ self._max_workers_set = max_workers is not None
+ self.max_workers = (max_workers or len(self.providers)) or 1
logger.info("Using %d threads for %d providers (%s)", self.max_workers, len(self.providers), self.providers)
+ def update(self, *args, **kwargs):
+ updated = super().update(*args, **kwargs)
+
+ if (len(self.providers) and not self._max_workers_set) and len(self.providers) != self.max_workers:
+ logger.debug("This pool will use %d threads from now on", len(self.providers))
+ self.max_workers = len(self.providers)
+
+ return updated
+
def list_subtitles_provider(self, provider, video, languages):
# list subtitles
provider_subtitles = None