We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ian's done a bit of that for vector tiles in his Tilepacks work here.
def fetch_tile(format_args): sleep_time = 0.5 * random.uniform(1.0, 1.7) response_info = [] while True: url = 'https://tile.mapzen.com/mapzen/vector/v1/{layer}/{zoom}/{x}/{y}.{fmt}?api_key={api_key}'.format(**format_args) try: start = time.time() resp = sess.get(url, timeout=(6.1, 30)) data = resp.content finish = time.time() response_info.append({ "url": url, "response status": resp.status_code, "server": resp.headers.get('Server'), "time to headers millis": int(resp.elapsed.total_seconds() * 1000), "time for content millis": int((finish - start) * 1000), "response length bytes": len(data), }) resp.raise_for_status() return (format_args, response_info, data) except requests.exceptions.RequestException as e: if isinstance(e, requests.exceptions.HTTPError): if e.response.status_code == 404: print("HTTP 404 -- {} while retrieving {}. Not trying again.".format( e.response.status_code, e.response.text, url) ) return (format_args, response_info, None) else: print("HTTP error {} -- {} while retrieving {}, retrying after {:0.2f} sec".format( e.response.status_code, e.response.text, url, sleep_time) ) else: print("{} while retrieving {}, retrying after {:0.2f} sec".format( type(e), url, sleep_time) ) time.sleep(sleep_time) sleep_time = min(sleep_time * 2.0, 30.0) * random.uniform(1.0, 1.7) except Exception as e: print("Ran into an unexpected exception: {}".format(e)) traceback.print_tb() raise
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Ian's done a bit of that for vector tiles in his Tilepacks work here.
The text was updated successfully, but these errors were encountered: