Download a photo to the the path(global varialbe `directory`)

    :param photo: The photo information include id and title
    :type photo: dict

def download_photo_async(photo):
    """Download a photo to the the path(global varialbe `directory`)

    :param photo: The photo information include id and title
    :type photo: dict
    """
    photo_id = photo['id']
    photo_title = photo['title']
    download_url = get_photo_url(photo_id)
    photo_format = download_url.split('.')[-1]
    photo_title = photo_title + '.' + photo_format
    file_path = directory + os.sep + photo_title
    logger.info('Download %s...', photo_title.encode('utf-8'))
    req = [grequests.get(download_url)]
    counter_lock = multiprocessing.Lock()
    for resp in grequests.map(req):
        with open(file_path, 'w') as f:
            f.write(resp.content)
            with counter_lock:
                global counter
                counter -= 1
        logger.info(
            'The number of pictures remaining: %s', counter
        )