'Returns the next waiting IncomingMessage object, or None if the
queue is empty. The optional _ping_ and _fetch_ parameters control
whether the modem is pinged (to allow new messages to be delivered
instantly, on those modems which support it) and queried for unread
messages in storage, which can both be disabled in case you\'re
already polling in a separate thread.'

def next_message(self, ping=True, fetch=True):

    if ping:
        self.ping()
    if fetch:
        self._fetch_stored_messages()
    if (not self.incoming_queue):
        return None
    return self.incoming_queue.pop(0)
