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 id, data 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)
    items = []
    with _conn(commit=True) as cur:
        cur.execute(cmd)
        result = cur.fetchall()
        if result:
            ids = [six.text_type(item[0]) for item in result]
            items = [item[1] for item in result]
            idlist = "','".join(ids)
            del_cmd = '''DELETE FROM {0} WHERE id IN ('{1}');'''.format(
                queue, idlist)

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

            cur.execute(del_cmd)
    return items