'Checks if there is actually any new data and sends it to the
connections if there are.
This should get called each time new data is available, even if it
is currently being executed, so that nothing gets missed'

@defer.inlineCallbacks
def on_notifier_poke(self):

    if (not self.connections):
        for stream in self.streams:
            stream.discard_updates_and_advance()
        return
    if self.is_looping:
        logger.debug('Noitifier    poke    loop    already    running')
        self.pending_updates = True
        return
    self.pending_updates = True
    self.is_looping = True
    try:
        while self.pending_updates:
            self.pending_updates = False
            with Measure(self.clock, 'repl.stream.get_updates'):
                for stream in self.streams:
                    stream.advance_current_token()
                for stream in self.streams:
                    if (stream.last_token == stream.upto_token):
                        continue
                    logger.debug('Getting    stream:    %s:    %s    ->    %s', stream.NAME, stream.last_token, stream.upto_token)
                    (updates, current_token) = (yield stream.get_updates())
                    logger.debug('Sending    %d    updates    to    %d    connections', len(updates), len(self.connections))
                    if updates:
                        logger.info('Streaming:    %s    ->    %s', stream.NAME, updates[(-1)][0])
                        stream_updates_counter.inc_by(len(updates), stream.NAME)
                    batched_updates = _batch_updates(updates)
                    for conn in self.connections:
                        for (token, row) in batched_updates:
                            try:
                                conn.stream_update(stream.NAME, token, row)
                            except Exception:
                                logger.exception('Failed    to    replicate')
        logger.debug('No    more    pending    updates,    breaking    poke    loop')
    finally:
        self.pending_updates = False
        self.is_looping = False
