Avoid NoneType on providers pool updates

pull/1831/head v1.0.5-beta.4
Vitiko 3 years ago
parent 134613711a
commit a783515ad4

@ -105,10 +105,12 @@ class SZProviderPool(ProviderPool):
# Check if the pool was initialized enough hours ago
self._check_lifetime()
providers = set(providers or [])
# Check if any new provider has been added
updated = set(providers) != self.providers or ban_list != self.ban_list
removed_providers = list(sorted(self.providers - set(providers)))
new_providers = list(sorted(set(providers) - self.providers))
updated = providers != self.providers or ban_list != self.ban_list
removed_providers = list(sorted(self.providers - providers))
new_providers = list(sorted(providers - self.providers))
# Terminate and delete removed providers from instance
for removed in removed_providers:
@ -128,8 +130,6 @@ class SZProviderPool(ProviderPool):
self.providers.difference_update(removed_providers)
self.providers.update(list(providers))
self.blacklist = blacklist
# Restart providers with new configs
for key, val in provider_configs.items():
# Don't restart providers that are not enabled
@ -154,6 +154,9 @@ class SZProviderPool(ProviderPool):
self.provider_configs = provider_configs
self.blacklist = blacklist or []
self.ban_list = ban_list or {'must_contain': [], 'must_not_contain': []}
return updated
def _check_lifetime(self):

Loading…
Cancel
Save