'Usage:
with stream_id_gen.get_next() as (stream_id, chained_id):
# ... persist event ...'

def get_next(self):

    with self._lock:
        self._current_max += 1
        next_id = self._current_max
        chained_id = self.chained_generator.get_current_token()
        self._unfinished_ids.append((next_id, chained_id))
    @contextlib.contextmanager
    def manager():
        try:
            (yield (next_id, chained_id))
        finally:
            with self._lock:
                self._unfinished_ids.remove((next_id, chained_id))
    return manager()
