def _connect(self):
        """ Open a connection to the quorum and for it to be established """
        def watcher(handle, type, state, path):
            self._cv.acquire()
            try:
                self._connected = True
                self._cv.notify()
            finally:
                self._cv.release()

        self._cv.acquire()
        try:
            self._handle = zookeeper.init(self._quorum, watcher, self._timeout)

            self._cv.wait(self._timeout/1000)
            if not self._connected:
                print >>sys.stderr, 'Unable to connecto the ZooKeeper cluster.'
                sys.exit(-1)
        finally:
            self._cv.release()
dataset/ETHPy150Open andreisavu/zookeeper-mq/zkmq.py/ZooKeeper._connect/original