Retrieve the next message in the mailbox
770268
def next_message
      message = nil

      if block_given?
        index = @messages.index do |msg|
          yield(msg) || msg.is_a?(SystemEvent)
        end

        message = @messages.slice!(index, 1).first if index
      else
        message = @messages.shift
      end

      message
    end
361889
def next(self):
        """"""
        if len(self.__data) or self._refresh():
            coll = self.__collection
            return coll.database._fix_outgoing(self.__data.popleft(), coll)
        else:
            raise StopIteration
777263
public Query getMails(String[] messageNumbers, String[] uids, boolean all) throws MessagingException, IOException {
	Query qry = new QueryImpl(all ? _fldnew : _flddo, 0, "query");
	Folder folder = _store.getFolder("INBOX");
	folder.open(Folder.READ_ONLY);
	try {
	    getMessages(qry, folder, uids, messageNumbers, startrow, maxrows, all);
	}
	finally {
	    folder.close(false);
	}
	return qry;
    }
1188194
def list_all_after(self, message_id, limit=None):
        
        return self.list_after(message_id, limit=limit).autopage()
1040991
def _next(self):
        
        c = self._get()
        if c == '/':
            p = self._peek()
            if p == '/':
                c = self._get()
                while c > '\n':
                    c = self._get()
                return c
            if p == '*':
                c = self._get()
                while 1:
                    c = self._get()
                    if c == '*':
                        if self._peek() == '/':
                            self._get()
                            return ' '
                    if c == '\000':
                        raise UnterminatedComment()

        return c
1125304
function next() {
		if ( count === len ) {
			debug( 'Finished all queries.' );
			out.meta.success = scount;
			out.meta.failure = fcount;
			return clbk( null, out );
		}
		if ( idx < len ) {
			debug( 'Querying for package: `%s` (%d)...', pkgs[idx], idx );
			request( pkgs[idx], opts, onResponse( pkgs[idx], idx ) );
			idx += 1;
		}
	}
1226467
def process_next_message(self, timeout):
        """"""
        message = self.worker_manager.receive(timeout)

        if isinstance(message, Acknowledgement):
            self.task_manager.task_start(message.task, message.worker)
        elif isinstance(message, Result):
            self.task_manager.task_done(message.task, message.result)
328004
public function listMessages()
    {
        $messages = array();
        fseek( $this->fh, 0 );
        // Skip the first mail as this is the mbox header
        $position = $this->findFirstMessage();
        if ( $position === false )
        {
            return $messages;
        }
        // Continue reading through the rest of the mbox
        do
        {
            $position = $this->findNextMessage();
            if ( $position !== false )
            {
                $messages[] = $position;
            }
        } while ( $position !== false );

        return $messages;
    }
221871
public function readMailbox()
    {
        $msg_cnt = imap_num_msg($this->conn);

        $messages = [];
        for ($i = 1; $i <= $msg_cnt; $i++) {
            $header = imap_headerinfo($this->conn, $i);
            $messages[] = [
                'index'     => trim($header->Msgno),
                'header'    => $header,
                'structure' => imap_fetchstructure($this->conn, $i)
            ];
        }
        $this->messages = $messages;
        return $this->messages;
    }
1300699
def send_messages(self, email_messages):
        
        if not email_messages:
            return

        num_sent = 0
        for message in email_messages:
            if self._send(message):
                num_sent += 1

        return num_sent
732354
def send_messages(self, messages):
        """"""
        msg_count = 0
        for message in messages:  # .message() triggers header validation
            message.message()
            email.outbox.append(message)
            msg_count += 1

        return msg_count
658695
def next_message(self):
        
        msg = self._session.next_message()
        if msg:
            return walk(self._from_nvim, msg)
680859
def get_next(self, query, **options):
        """"""
        iterator = EventsPageIterator(self.client, '/events', query, options)
        result = iterator.next()
        return (result, iterator.sync)
449222
def getMessage(self):
        
        if isinstance(self.msg, numpy.ndarray):
            msg = self.array2string(self.msg)
        else:
            msg = str(self.msg)
        if self.args:
            a2s = self.array2string
            if isinstance(self.args, Dict):
                args = {k: (a2s(v) if isinstance(v, numpy.ndarray) else v)
                        for (k, v) in self.args.items()}
            elif isinstance(self.args, Sequence):
                args = tuple((a2s(a) if isinstance(a, numpy.ndarray) else a)
                             for a in self.args)
            else:
                raise TypeError("Unexpected input '%s' with type '%s'" % (self.args,
                                                                          type(self.args)))
            msg = msg % args
        return msg
1158139
def auto_reply_message(self):
        
        if self._auto_reply is None:
            r = requests.get('https://outlook.office.com/api/v2.0/me/MailboxSettings/AutomaticRepliesSetting',
                             headers=self._headers)
            check_response(r)
            self._auto_reply = r.json().get('InternalReplyMessage')

        return self._auto_reply
2603
def _get_message(self, block=True, timeout=0.1, get_partition_info=None,
                     update_offset=True):
        
        start_at = time.time()
        while self.queue.empty():
            # We're out of messages, go grab some more.
            log.debug('internal queue empty, fetching more messages')
            with FetchContext(self, block, timeout):
                self._fetch()

            if not block or time.time() > (start_at + timeout):
                break

        try:
            partition, message = self.queue.get_nowait()

            if update_offset:
                # Update partition offset
                self.offsets[partition] = message.offset + 1

                # Count, check and commit messages if necessary
                self.count_since_commit += 1
                self._auto_commit()

            if get_partition_info is None:
                get_partition_info = self.partition_info
            if get_partition_info:
                return partition, message
            else:
                return message
        except queue.Empty:
            log.debug('internal queue empty after fetch - returning None')
            return None
114001
def get(self):
        """"""

        # First retrieve all header bytes in order to extract
        # length of the message remainder.
        header = ''
        while len(header) < self.HEADER_LENGTH:
            chunk = self._sock.recv(self.HEADER_LENGTH - len(header))
            chunk = chunk.decode() if self._encode else chunk
            if chunk == '':
                return None
            header += chunk
        length = int(header)

        # Then retrieve the remainder of the message.
        message = ''
        while len(message) < length:
            chunk = self._sock.recv(length - len(message))
            chunk = chunk.decode() if self._encode else chunk
            if chunk == '':
                return None
            message += chunk
        return message