Pop one or more or all items from the queue return them.

def pop(queue, quantity=1, is_runner=False):
    '''
    Pop one or more or all items from the queue return them.
    '''
    cmd = 'SELECT name FROM {0}'.format(queue)
    if quantity != 'all':
        try:
            quantity = int(quantity)
        except ValueError as exc:
            error_txt = ('Quantity must be an integer or "all".\n'
                         'Error: "{0}".'.format(exc))
            raise SaltInvocationError(error_txt)
        cmd = ''.join([cmd, ' LIMIT {0}'.format(quantity)])
    log.debug('SQL Query: %s', cmd)
    con = _conn(queue)
    items = []
    with con:
        cur = con.cursor()
        result = cur.execute(cmd).fetchall()
        if result:
            items = [item[0] for item in result]
            itemlist = '","'.join(items)
            _quote_escape(itemlist)
            del_cmd = '''DELETE FROM {0} WHERE name IN ("{1}")'''.format(
                queue, itemlist)

            log.debug('SQL Query: %s', del_cmd)

            cur.execute(del_cmd)
        con.commit()
    if is_runner:
        items = [salt.utils.json.loads(item[0].replace("'", '"')) for item in result]
    log.info(items)
    return items