summaryrefslogtreecommitdiff
path: root/config.py
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2022-08-23 18:27:09 -0700
committerScott Gasch <[email protected]>2022-08-23 18:27:09 -0700
commit119692e4487278e5d19c06cfe7dc062c2bd7efc5 (patch)
tree683303fbf1f023bed39d21c618d7ce56df18a2fb /config.py
parentf9e0d471e6d57b62cdc21a904ae48a2a43331bec (diff)
Update requirements; new homeassistant dep. Also don't import kazoo
unless we try to load args from zookeeper.
Diffstat (limited to 'config.py')
-rw-r--r--config.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/config.py b/config.py
index 1a362a3..a98db57 100644
--- a/config.py
+++ b/config.py
@@ -90,9 +90,6 @@ import re
import sys
from typing import Any, Dict, List, Optional, Tuple
-from kazoo.client import KazooClient
-from kazoo.protocol.states import WatchedEvent
-
import scott_secrets
# This module is commonly used by others in here and should avoid
@@ -225,7 +222,7 @@ class Config:
# A zookeeper client that is lazily created so as to not incur
# the latency of connecting to zookeeper for programs that are
# not reading or writing their config data into zookeeper.
- self.zk: Optional[KazooClient] = None
+ self.zk: Optional[Any] = None
# Per known zk file, what is the max version we have seen?
self.max_version: Dict[str, int] = {}
@@ -378,7 +375,7 @@ class Config:
sys.argv.append(value)
arg = ''
- def _process_dynamic_args(self, event: WatchedEvent):
+ def _process_dynamic_args(self, event):
assert self.zk
logger = logging.getLogger(__name__)
contents, meta = self.zk.get(event.path, watch=self._process_dynamic_args)
@@ -422,6 +419,8 @@ class Config:
if loadfile is not None:
zkpath = None
if loadfile[:3] == 'zk:':
+ from kazoo.client import KazooClient
+
try:
if self.zk is None:
self.zk = KazooClient(
@@ -544,6 +543,8 @@ class Config:
zkpath = re.sub(r'//+', '/', zkpath)
try:
if not self.zk:
+ from kazoo.client import KazooClient
+
self.zk = KazooClient(
hosts=scott_secrets.ZOOKEEPER_NODES,
use_ssl=True,