def FetchMetadata(self, paths, callback):
    """Asynchronously fetches metadata for the specified path(s) and
    on completion invokes the callback with the retrieved metadata
    value. 'paths' can be iterable over multiple metadata to fetch;
    if not, adds it to a list.
    """
    metadata = {}

    def _OnFetch(path, callback, response):
      if response.code == 200:
        metadata[path] = response.body.strip()
      else:
        logging.error("error fetching '%s': %s", path, response.error)
      callback()

    if type(paths) in (unicode, str):
      paths = [paths]

    with util.Barrier(partial(callback, metadata)) as b:
      for path in paths:
        logging.info('fetching metadata from %s' % self._GetQueryURL(path))
        http_client = httpclient.AsyncHTTPClient()
        http_client.fetch(self._GetQueryURL(path), partial(_OnFetch, path, b.Callback()),
                                connect_timeout=1, request_timeout=5)
dataset/ETHPy150Open viewfinderco/viewfinder/backend/base/ami_metadata.py/Metadata.FetchMetadata/original