Pop one or more or all items from the queue return them.
977826
def pop(queue, quantity=1, is_runner=False):
    '''
    
    '''
    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
1325352
def popitem(self):
        """"""
        try:
            key = next(iter(self.__order))
        except StopIteration:
            raise KeyError('%s is empty' % self.__class__.__name__)
        else:
            return (key, self.pop(key))
351350
def pop(self):
        
        if len(self.stack):      
            popped = self.stack.pop()
            #log.debug('pop: (%s)\n%s', Repr(popped), Repr(self.stack))
            return popped
        else:
            #log.debug('stack empty, not-popped')
            pass
        return None
102764
function sqPop(queue, index, count, item) {
  var idx = index[item]
  var top = queue[count-1]
  queue[idx] = top
  index[top] = idx
}
785030
def pop_all_queues(self):
        
        output = []
        with self.lock:
            for q in self.queue:
                output.extend(list(q.queue))
                q.queue.clear()

        return output
403522
def pop(self, n=None):
        """"""
        self.error_buffer.check()

        envs = []

        if n is None:
            while True:
                try:
                    envs += self.ready.get(block=False)
                except queue.Empty:
                    break
        else:
            sync_timeout = 10 * 60
            start = time.time()

            wait_time = 1
            while len(envs) < n:
                try:
                    extra_logger.info('[%s] Waiting for %d envs, currently at %d, sleeping for %d', self.label, n, len(envs), wait_time)
                    envs += self.ready.get(timeout=wait_time)
                except queue.Empty:
                    self.error_buffer.check()
                wait_time = min(wait_time * 2, 30)
                delta = time.time() - start
                if delta > sync_timeout:
                    raise FatalError("Waited %.0fs to obtain envs, timeout was %.0fs. (Obtained %d/%d envs.)" % (delta, sync_timeout, len(envs), n))

        return envs
632488
def pop(self):
        """"""

        if self._count == 0:
            raise StreamEmptyError("Pop called on buffered stream walker without any data", selector=self.selector)

        while True:
            curr = self.engine.get(self.storage_type, self.offset)
            self.offset += 1

            stream = DataStream.FromEncoded(curr.stream)
            if self.matches(stream):
                self._count -= 1
                return curr
925540
def pop(self, key, default=None):
        
        with self.lock:
            try:
                item = OrderedDict.__getitem__(self, key)
                del self[key]
                return item[0]
            except KeyError:
                return default
626523
def pop_all(self):
        
        ret = ExitStack()
        ret._context_stack.append(self._context_stack.pop())
        self._context_stack.append([])
375075
def pop_all(self):
        """"""
        new_stack = type(self)()
        new_stack._exit_callbacks = self._exit_callbacks
        self._exit_callbacks = deque()
        return new_stack
1194943
def pop(self):
        
        if not self.items:
            raise KeyError("Set is empty")

        elem = self.items[-1]
        del self.items[-1]
        del self.map[elem]
        return elem
84171
def pop(self):
        
        stack = getattr(self._local, "stack", None)
        if stack is None:
            return None
        elif len(stack) == 1:
            release_local(self._local)
            return stack[-1]
        else:
            return stack.pop()
1086250
def pop_all(self):
        
        with self.lock:
            if self.please_stop:
                return [THREAD_STOP]
            if self.db.status.end == self.start:
                return []

            output = []
            for i in range(self.start, self.db.status.end):
                output.append(self.db[str(i)])

            self.start = self.db.status.end
            return output
1049552
function pop(arr) {
    return {
        array: arr.slice(0, arr.length - 1),
        val: last(arr)
    };
}
614502
def pop_one(self):
        
        with self.lock:
            if self.closed:
                return [THREAD_STOP]
            elif not self.queue:
                return None
            else:
                v =self.queue.pop()
                if v is THREAD_STOP:  # SENDING A STOP INTO THE QUEUE IS ALSO AN OPTION
                    self.closed.go()
                return v
925303
def pop(self, queue_name):
        
        task_id = self.conn.lpop(queue_name)
        data = self.conn.get(task_id)
        self.conn.delete(task_id)
        return data
396119
def pop(self, key, timeout=1, is_async=False, only_read=False):
        
        if key not in self.cache_items:
            return None
        return self.cache_items.pop(key)[key]