<s> import logger <EOL> log = logger . getLogger ( __name__ ) <EOL> class PeerSocketPool ( list ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( list , self ) . __init__ ( self , * args , ** kwargs ) <EOL> self . purged_connections = [ ] <EOL> def purge ( self , peer ) : <EOL> self . purged_connections . remove ( peer ) <EOL> def remove ( self , other ) : <EOL> if other . peer in self . purged_connections : <EOL> return False <EOL> for idx , i in enumerate ( self ) : <EOL> if i . peer == other . peer : <EOL> conn = self . pop ( idx ) <EOL> self . purged_connections . append ( conn . peer ) <EOL> return conn <EOL> raise AttributeError ( "<STR_LIT>" % <EOL> ( type ( self ) , repr ( other ) ) ) <EOL> def __contains__ ( self , other ) : <EOL> for i in self : <EOL> if i . peer == other : <EOL> return True <EOL> return False <EOL> def __getitem__ ( self , key ) : <EOL> for i in self : <EOL> if i . peer == key : <EOL> return i <EOL> raise KeyError </s>
