- zk = KazooClient(
- hosts=scott_secrets.ZOOKEEPER_NODES,
- use_ssl=True,
- verify_certs=False,
- keyfile=scott_secrets.ZOOKEEPER_CLIENT_CERT,
- keyfile_password=scott_secrets.ZOOKEEPER_CLIENT_PASS,
- certfile=scott_secrets.ZOOKEEPER_CLIENT_CERT,
- )
- zk.start()
- if zk.exists(zkpath):
- zk.delete(zkpath)
- zk.create(zkpath, data.encode())
+ if not ZK:
+ ZK = KazooClient(
+ hosts=scott_secrets.ZOOKEEPER_NODES,
+ use_ssl=True,
+ verify_certs=False,
+ keyfile=scott_secrets.ZOOKEEPER_CLIENT_CERT,
+ keyfile_password=scott_secrets.ZOOKEEPER_CLIENT_PASS,
+ certfile=scott_secrets.ZOOKEEPER_CLIENT_CERT,
+ )
+ ZK.start()
+ if not ZK.exists(zkpath):
+ ZK.create(zkpath, data.encode())
+ else:
+ ZK.set(zkpath, data.encode())