Don't import module "etcd3gw" if etcd3gw backend is not used.

If module etcd3gw is not required for used backend,
then no need to have it installed and imported.
Otherwise we always have ugly log error:
Could not load 'oslo_cache.etcd3gw': No module named 'etcd3gw': ModuleNotFoundError: No module named 'etcd3gw

Closes-Bug: 1928318
Change-Id: Icbe6dc3e93b4d2fec1ceb88366027294e49d7032
This commit is contained in:
Mitya_Eremeev 2021-05-21 19:50:53 +03:00 committed by mitya-eremeev-2
parent d89cc82be3
commit 40946a9349
1 changed files with 2 additions and 1 deletions

View File

@ -14,7 +14,6 @@
"""dogpile.cache backend that uses etcd 3.x for storage"""
from dogpile.cache import api
import etcd3gw
from oslo_cache import core
from oslo_serialization import jsonutils
@ -40,6 +39,8 @@ class Etcd3gwCacheBackend(api.CacheBackend):
self.host = arguments.get('host', self.DEFAULT_HOST)
self.port = arguments.get('port', self.DEFAULT_PORT)
self.timeout = int(arguments.get('timeout', self.DEFAULT_TIMEOUT))
# module etcd3gw is only required when etcd3gw backend is used
import etcd3gw
self._client = etcd3gw.client(host=self.host,
port=self.port,
timeout=self.timeout)