def _fetch(self, url, body, log_exceptions=True, attempts=3): full_url = 'http://{host}:{port:d}{prefix}{url}'.format( host=self._host, port=self._port, prefix=self._url_prefix, url=url) last_exception = None attempt = 0 while attempt < attempts: attempt += 1 if last_exception: logger.info("Retrying...") self._wait() # wait for a bit and retry try: response = urlopen(full_url, body, self._connect_timeout) break except (URLError, socket.timeout) as e: last_exception = e if log_exceptions: logger.exception("Failed connecting to remote scheduler %r", self._host) continue else: raise RPCError( "Errors (%d attempts) when connecting to remote scheduler %r" % (attempts, self._host), last_exception ) return response.read().decode('utf-8')
def _fetch(self, url, body, log_exceptions=True, attempts=3): full_url = 'http://{host}:{port:d}{prefix}{url}'.format( host=self._host, port=self._port, prefix=self._url_prefix, url=url) last_exception = None attempt = 0 while attempt < attempts: attempt += 1 if last_exception: logger.info("Retrying...") self._wait() # wait for a bit and retry try: response = urlopen(full_url, body, self._connect_timeout) break except URLError as e: last_exception = e if log_exceptions: logger.exception( "Failed connecting to remote scheduler %r", self._host) continue else: raise RPCError( "Errors (%d attempts) when connecting to remote scheduler %r" % (attempts, self._host), last_exception) return response.read().decode('utf-8')
def fetch(self, full_url, body, timeout): body = urlencode(body).encode('utf-8') return urlopen(full_url, body, timeout).read().decode('utf-8')
def fetch(self, full_url, body, timeout): try: body = urlencode(body).encode('utf-8') return urlopen(full_url, body, timeout).read().decode('utf-8') except (URLError, socket.timeout) as e: raise FetcherException(e)
def fetch(self, full_url, body, timeout): body = urlencode(body).encode("utf-8") return urlopen(full_url, body, timeout).read().decode("utf-8")
def _fetch_json(self): """Returns the json representation of the dep graph""" print("Fetching from url: " + self.graph_url) resp = urlopen(self.graph_url).read() return json.loads(resp.decode('utf-8'))
def fetch(self, full_url, body, timeout): req = self._create_request(full_url, body=body) return urlopen(req, timeout=timeout).read().decode('utf-8')