Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add client_id support

  • Loading branch information...
commit 75473fdc10b4c573e6c4610668d68df5dff5d51d 1 parent 0df608e
@labisso labisso authored
Showing with 18 additions and 2 deletions.
  1. +4 −0 kazoo/client.py
  2. +14 −2 kazoo/zkclient.py
View
4 kazoo/client.py
@@ -94,6 +94,10 @@ def remove_listener(self, listener):
"""
self.state_listeners.discard(listener)
+ @property
+ def client_id(self):
+ return self.zk.client_id
+
def connect(self, timeout=None):
"""Initiate connection to ZK
View
16 kazoo/zkclient.py
@@ -53,9 +53,10 @@ class ZooKeeperClient(object):
DEFAULT_TIMEOUT = 10000
- def __init__(self, hosts, watcher=None, timeout=10000):
+ def __init__(self, hosts, watcher=None, timeout=10000, client_id=None):
self._hosts = hosts
self._watcher = watcher
+ self._provided_client_id = client_id
if timeout is None:
timeout = self.DEFAULT_TIMEOUT
self._timeout = timeout
@@ -71,6 +72,12 @@ def __init__(self, hosts, watcher=None, timeout=10000):
def connected(self):
return self._connected
+ @property
+ def client_id(self):
+ if self._handle is not None:
+ return zookeeper.client_id(self._handle)
+ return None
+
def get_sync_strategy(self):
return self._sync
@@ -114,7 +121,12 @@ def connect_async(self):
"""
cb = self._wrap_session_callback(self._session_callback)
- self._handle = zookeeper.init(self._hosts, cb, self._timeout)
+ if self._provided_client_id:
+ self._handle = zookeeper.init(self._hosts, cb, self._timeout,
+ self._provided_client_id)
+ else:
+ self._handle = zookeeper.init(self._hosts, cb, self._timeout)
+
return self._connected_async_result
def connect(self, timeout=None):
Please sign in to comment.
Something went wrong with that request. Please try again.