'Force ZK to expire a client session
:param client_id: id of client to expire. If unspecified, the id of
self.client will be used.'

def expire_session(self, client_id=None):

    client_id = (client_id or self.client.client_id)
    lost = threading.Event()
    safe = threading.Event()
    def watch_loss(state):
        if (state == KazooState.LOST):
            lost.set()
        if (lost.is_set() and (state == KazooState.CONNECTED)):
            safe.set()
            return True
    self.client.add_listener(watch_loss)
    self.client._call(_SESSION_EXPIRED, None)
    lost.wait(5)
    if (not lost.isSet()):
        raise Exception('Failed    to    get    notified    of    session    loss')
    safe.wait(15)
    if (not safe.isSet()):
        raise Exception('Failed    to    see    client    reconnect')
    self.client.retry(self.client.get_async, '/')
