def FetchAsync(self, url, username=None, password=None):
   """Fetches a file asynchronously, and returns a Future with the result.
   """
   if self._base_path is not None:
     url = '%s/%s' % (self._base_path, url)
   rpc = urlfetch.create_rpc()
   urlfetch.make_fetch_call(rpc, url, headers=_MakeHeaders(username, password))
   return Future(delegate=_AsyncFetchDelegate(rpc))
예제 #2
0
 def FetchAsync(self, url, username=None, password=None):
     """Fetches a file asynchronously, and returns a Future with the result.
 """
     rpc = urlfetch.create_rpc()
     urlfetch.make_fetch_call(rpc,
                              self._FromBasePath(url),
                              headers=_MakeHeaders(username, password))
     return Future(delegate=_AsyncFetchDelegate(rpc))
예제 #3
0
 def FetchAsync(self, url, username=None, password=None):
   """Fetches a file asynchronously, and returns a Future with the result.
   """
   rpc = urlfetch.create_rpc()
   urlfetch.make_fetch_call(rpc,
                            self._FromBasePath(url),
                            headers=_MakeHeaders(username, password))
   return Future(delegate=_AsyncFetchDelegate(rpc))
예제 #4
0
 def FetchAsync(self, url):
     """Fetches a file asynchronously, and returns a Future with the result.
 """
     rpc = urlfetch.create_rpc()
     if self._base_path is not None:
         urlfetch.make_fetch_call(rpc, self._base_path + "/" + url, headers={"Cache-Control": "max-age=0"})
     else:
         urlfetch.make_fetch_call(rpc, url, headers={"Cache-Control": "max-age=0"})
     return Future(delegate=_AsyncFetchDelegate(rpc))
 def FetchAsync(self, url, username=None, password=None):
     """Fetches a file asynchronously, and returns a Future with the result.
 """
     if self._base_path is not None:
         url = '%s/%s' % (self._base_path, url)
     rpc = urlfetch.create_rpc()
     urlfetch.make_fetch_call(rpc,
                              url,
                              headers=_MakeHeaders(username, password))
     return Future(delegate=_AsyncFetchDelegate(rpc))
예제 #6
0
 def FetchAsync(self, url):
     """Fetches a file asynchronously, and returns a Future with the result.
 """
     rpc = urlfetch.create_rpc()
     if self._base_path is not None:
         urlfetch.make_fetch_call(rpc,
                                  self._base_path + '/' + url,
                                  headers={'Cache-Control': 'max-age=0'})
     else:
         urlfetch.make_fetch_call(rpc,
                                  url,
                                  headers={'Cache-Control': 'max-age=0'})
     return Future(delegate=_AsyncFetchDelegate(rpc))
예제 #7
0
 def FetchAsync(self, url, username=None, password=None):
   """Fetches a file asynchronously, and returns a Future with the result.
   """
   rpc = urlfetch.create_rpc(deadline=20)
   headers = _MakeHeaders(username, password)
   import logging
   if self._base_path is not None:
     logging.info('%s/%s' % (self._base_path, url))
     urlfetch.make_fetch_call(rpc,
                              '%s/%s' % (self._base_path, url),
                              headers=headers)
   else:
     logging.info(url)
     urlfetch.make_fetch_call(rpc, url, headers=headers)
   return Future(delegate=_AsyncFetchDelegate(rpc))
예제 #8
0
 def FetchAsync(self, url, username=None, password=None):
     """Fetches a file asynchronously, and returns a Future with the result.
 """
     rpc = urlfetch.create_rpc(deadline=20)
     headers = _MakeHeaders(username, password)
     import logging
     if self._base_path is not None:
         logging.info('%s/%s' % (self._base_path, url))
         urlfetch.make_fetch_call(rpc,
                                  '%s/%s' % (self._base_path, url),
                                  headers=headers)
     else:
         logging.info(url)
         urlfetch.make_fetch_call(rpc, url, headers=headers)
     return Future(delegate=_AsyncFetchDelegate(rpc))
예제 #9
0
    def FetchAsync(self, url, username=None, password=None, access_token=None):
        """Fetches a file asynchronously, and returns a Future with the result.
    """

        def process_result(result):
            if result.status_code == 429:
                if self._retries_left == 0:
                    logging.error("Still throttled. Giving up.")
                    return result
                self._retries_left -= 1
                logging.info("Throttled. Trying again in %s seconds." % _RETRY_DELAY_SECONDS)
                time.sleep(_RETRY_DELAY_SECONDS)
                return self.FetchAsync(url, username, password, access_token).Get()
            return result

        rpc = urlfetch.create_rpc(deadline=20)
        urlfetch.make_fetch_call(rpc, self._FromBasePath(url), headers=_MakeHeaders(username, password, access_token))
        return Future(callback=lambda: process_result(rpc.get_result()))
예제 #10
0
    def FetchAsync(self, url, username=None, password=None, access_token=None):
        """Fetches a file asynchronously, and returns a Future with the result.
    """
        def process_result(result):
            if result.status_code == 429:
                if self._retries_left == 0:
                    logging.error('Still throttled. Giving up.')
                    return result
                self._retries_left -= 1
                logging.info('Throttled. Trying again in %s seconds.' %
                             _RETRY_DELAY_SECONDS)
                time.sleep(_RETRY_DELAY_SECONDS)
                return self.FetchAsync(url, username, password,
                                       access_token).Get()
            return result

        rpc = urlfetch.create_rpc(deadline=20)
        urlfetch.make_fetch_call(rpc,
                                 self._FromBasePath(url),
                                 headers=_MakeHeaders(username, password,
                                                      access_token))
        return Future(callback=lambda: process_result(rpc.get_result()))