':type pokemon: Pokemon'

def release_pokemon(self, pokemon):

    try:
        if self.bot.config.test:
            candy_awarded = 1
        else:
            request = self.bot.api.create_request()
            request.release_pokemon(pokemon_id=pokemon.unique_id)
            response_dict = request.call()
            candy_awarded = response_dict['responses']['RELEASE_POKEMON']['candy_awarded']
    except KeyError:
        return
    candy = inventory.candies().get(pokemon.pokemon_id)
    candy.add(candy_awarded)
    inventory.pokemons().remove(pokemon.unique_id)
    self.bot.metrics.released_pokemon()
    self.emit_event('pokemon_release', data={'pokemon': pokemon.name, 'iv': pokemon.iv, 'cp': pokemon.cp, 'ivcp': pokemon.ivcp, 'candy': candy.quantity, 'candy_type': candy.type}, formatted='Released    {}    (CP:    {},    IV:    {},    IVCP:    {:.2f})    You    now    have    {}    {}    candies'.format(pokemon.name, pokemon.cp, pokemon.iv, pokemon.ivcp, candy.quantity, candy.type))
    with self.bot.database as conn:
        c = conn.cursor()
        c.execute("SELECT    COUNT(name)    FROM    sqlite_master    WHERE    type='table'    AND    name='transfer_log'")
    result = c.fetchone()
    while True:
        if (result[0] == 1):
            conn.execute('INSERT    INTO    transfer_log    (pokemon,    iv,    cp)    VALUES    (?,    ?,    ?)', (pokemon.name, pokemon.iv, pokemon.cp))
            break
        else:
            self.emit_event('transfer_log', sender=self, level='info', formatted='transfer_log    table    not    found,    skipping    log')
            break
    action_delay(self.transfer_wait_min, self.transfer_wait_max)
