def download_photo(photo):
counter_lock = multiprocessing.Lock()<EOL>photo_id = photo['<STR_LIT:id>']<EOL>photo_title = photo['<STR_LIT:title>']<EOL>download_url = get_photo_url(photo_id)<EOL>photo_format = download_url.split('<STR_LIT:.>')[-<NUM_LIT:1>]<EOL>photo_title = photo_title + '<STR_LIT:.>' + photo_format<EOL>file_path = directory + os.sep + photo_title<EOL>logger.info('<STR_LIT>', photo_title.encode('<STR_LIT:utf-8>'))<EOL>resp = requests.get(download_url)<EOL>with open(file_path, '<STR_LIT:w>') as f:<EOL><INDENT>f.write(resp.content)<EOL>with counter_lock:<EOL><INDENT>global counter<EOL>counter -= <NUM_LIT:1><EOL><DEDENT>logger.info(<EOL>'<STR_LIT>', counter<EOL>)<EOL><DEDENT>
Download a photo to the the path(global varialbe `directory`)

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