def addStreamAndSetStreamID(self, stream):
        # find the next available stream ID and assign it to the requesting
        # stream. fail if we can't assign an ID (should never happen).
        if len(self._streams) == self._max_streams:
            msg = ("Circuit {} tried to add a stream, but it's stream map was "
                   "full. This is a bug.".format(self.circuit_id))
            raise RuntimeError(msg)

        assigned = False
        for _ in xrange(self._max_streams):
            _id = next(self._ctr)
            if _id not in self._streams:
                self._streams[_id] = stream
                stream.stream_id = _id
                assigned = True
                break

        if not assigned:
            msg = ("Circuit {} failed to assign a requesting stream an ID, "
                   "even though it's stream map only contains {} streams. "
                   "This is a bug."
                   .format(self.circuit_id, len(self._streams)))
            raise RuntimeError(msg)

        msg = ("Circuit {} added a new stream {}."
               .format(self.circuit_id, stream.stream_id))
        logging.debug(msg)
Edit a channel.
dataset/ETHPy150Open nskinkel/oppy/oppy/circuit/circuit.py/Circuit.addStreamAndSetStreamID--crossover with--dataset/ETHPy150Open ebu/radiodns-plugit/RadioDns-PlugIt/radiovis/actions.py/radiovis_gallery_edit