def watch(self, key, recurse=False, timeout=0, index=None):
        ret = {
            'key': key,
            'value': None,
            'changed': False,
            'mIndex': 0,
            'dir': False
        }
        try:
            result = self.read(key, recursive=recurse, wait=True, timeout=timeout, waitIndex=index)
        except EtcdUtilWatchTimeout:
            try:
                result = self.read(key)
            except etcd.EtcdKeyNotFound:
                log.debug("etcd: key was not created while watching")
                return ret
            except __HOLE__:
                return {}
            if result and getattr(result, "dir"):
                ret['dir'] = True
            ret['value'] = getattr(result, 'value')
            ret['mIndex'] = getattr(result, 'modifiedIndex')
            return ret
        except (etcd.EtcdConnectionFailed, MaxRetryError):
            # This gets raised when we can't contact etcd at all
            log.error("etcd: failed to perform 'watch' operation on key {0} due to connection error".format(key))
            return {}
        except ValueError:
            return {}

        if recurse:
            ret['key'] = getattr(result, 'key', None)
        ret['value'] = getattr(result, 'value', None)
        ret['dir'] = getattr(result, 'dir', None)
        ret['changed'] = True
        ret['mIndex'] = getattr(result, 'modifiedIndex')
        return ret
dataset/ETHPy150Open saltstack/salt/salt/utils/etcd_util.py/EtcdClient.watch