def __init__(self, hosts, root, name='Lock'): self.root = root self.name = name self.lock_name = None self.condition = threading.Condition(threading.RLock()) ZKClient.__init__(self, hosts) self.start() @self.zk.ChildrenWatch(self.root) def _on_children_change(children): Lock_logger.info( '_on_children_change children are[%s]' % children) with self.condition: self.condition.notifyAll()
def __init__(self, hosts, root, count): self.root = root self.name = 'barriers' self.count = count self.condition = threading.Condition(threading.RLock()) ZKClient.__init__(self, hosts) self.start() @self.zk.ChildrenWatch(self.root) def _on_children_change(children): Barriers_logger.info('_on_children_change children are[%s]' % children) with self.condition: self.condition.notifyAll()
def __init__(self, hosts, root): self.root = root self.name = 'queue' self.condition = threading.Condition(threading.RLock()) ZKClient.__init__(self, hosts) self.start() @self.zk.ChildrenWatch(self.root) def _on_children_change(children): ZKQueue_logger.info('_on_children_change children are[%s]' % children) with self.condition: self.condition.notifyAll() self.zklock = ZKLock(hosts='127.0.0.1:2181', root='/my_Lock_test')