#NEWLINE# def _getToken( self , destIp , destPort ) : #NEWLINE# #INDENT# '\n        \\pre transmittersLock is already acquired.\n        ' #NEWLINE# with self . transmittersLock : #NEWLINE# #INDENT# self . _cleanupTransmitter ( ) #NEWLINE# found = False #NEWLINE# while ( not found ) : #NEWLINE# #INDENT# token = random . randint ( 0 , 255 ) #NEWLINE# alreadyUsed = False #NEWLINE# for ( kIp , kPort , kToken , kMessageId ) in self . transmitters . keys ( ) : #NEWLINE# #INDENT# if ( ( destIp == kIp ) and ( destPort == kPort ) and ( token == kToken ) ) : #NEWLINE# #INDENT# alreadyUsed = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( not alreadyUsed ) : #NEWLINE# #INDENT# found = True #NEWLINE# #UNINDENT# #UNINDENT# return token