#NEWLINE# def addStreamAndSetStreamID( self , stream ) : #NEWLINE# #INDENT# "Register the new *stream* on this circuit.\n\n        Set the stream's stream_id and add it to this circuit's stream map.\n\n        :param oppy.stream.stream.Stream stream: stream to add to this circuit\n        " #NEWLINE# if ( len ( self . _streams ) == self . _max_streams ) : #NEWLINE# #INDENT# msg = "Circuit {} tried to add a stream, but it's stream map was full. This is a bug." . format ( self . circuit_id ) #NEWLINE# raise RuntimeError ( msg ) #NEWLINE# #UNINDENT# assigned = False #NEWLINE# for _ in xrange ( self . _max_streams ) : #NEWLINE# #INDENT# _id = next ( self . _ctr ) #NEWLINE# if ( _id not in self . _streams ) : #NEWLINE# #INDENT# self . _streams [ _id ] = stream #NEWLINE# stream . stream_id = _id #NEWLINE# assigned = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( not assigned ) : #NEWLINE# #INDENT# 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 ) ) #NEWLINE# raise RuntimeError ( assigned ) #NEWLINE# #UNINDENT# msg = 'Circuit {} added a new stream {}.' . format ( self . circuit_id , stream . stream_id ) #NEWLINE# logging . debug ( msg )