标签:spl obj ref count efi test etc type python
import etcd3
etcd = etcd3.client(host="192.168.5.41", port=2379,
ca_cert="E://ssl/kube-ca.pem",
cert_cert="E://ssl/kube-etcd-192-168-5-41.pem",
cert_key="E://ssl/kube-etcd-192-168-5-41-key.pem")
print(etcd) ## <etcd3.client.Etcd3Client object at 0x0000000002EC4240>
result = etcd.get("/testkey")
print(type(result)) ## <class 'tuple'>
print(result[0]) ## b'111111 '
watch_count = 0
events_iterator, cancel = etcd.watch_prefix("/testkey/")
for event in events_iterator:
print(event)
## <class 'etcd3.events.PutEvent'> key=b'/testkey/5' value=b'1234'
event_str = str(event)
print(isinstance(event, etcd3.events.PutEvent)) ## True
print("key = %s " % event_str.split(' ')[2].split('=')[1])
## key = b'/testkey/5'
watch_count += 1
if watch_count > 10:
cancel()
标签:spl obj ref count efi test etc type python
原文地址:https://www.cnblogs.com/zhangjxblog/p/12168341.html