import requests


def _download_tiles(tile_list, session=None):
    """
    Downloads tiles from a tile list generated by _generate_tile_list().
    """
    if session is None:
        session = requests.Session()

    tile_data = {}
    for i, (x, y, url) in enumerate(tile_list):
        response = session.get(url, stream=True)
        tile_data[(x, y)] = response.content
        del response

    return tile_data