def removeStream(self, stream):
        '''Unregister *stream* from this circuit.

        Remove the stream from this circuit's stream map and send a
        RelayEndCell. If the number of streams on this circuit drops to
        zero, check with the circuit manager to see if this circuit should
        be destroyed. If so, tear down the circuit.

        :param oppy.stream.stream.Stream stream: stream to unregister
        '''
        try:
            del self._streams[stream.stream_id]
            cell = RelayEndCell.make(self.circuit_id, stream.stream_id)
            self._encryptAndSendCell(cell)
        except __HOLE__:
            msg = ("Circuit {} notified that stream {} was closed, but "
                   "the circuit has no reference to this stream."
                   .format(self.circuit_id, stream.stream_id))
            logging.debug(msg)
            return

        if len(self._streams) == 0:
            if self._circuit_manager.shouldDestroyCircuit(self) is True:
                self._sendDestroyCell()
                self._closeCircuit()
                msg = "Destroyed unused circuit {}.".format(self.circuit_id)
                logging.debug(msg)
dataset/ETHPy150Open nskinkel/oppy/oppy/circuit/circuit.py/Circuit.removeStream