#NEWLINE# def reduce_addr_size( self , addr , size ) : #NEWLINE# #INDENT# '\n        reduce the number of sockets pooled on the specified address to size\n        returns a greenlet that can be joined on to wait for all sockets to close\n        ' #NEWLINE# addr_socks = self . free_socks_by_addr . get ( addr , [ ] ) #NEWLINE# if ( len ( addr_socks ) <= size ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# num_culling = ( len ( culled ) - size ) #NEWLINE# culled = sorted ( [ ( self . sock_idle_times [ e ] , e ) for e in addr_socks ] ) [ ( - num_culling ) : ] #NEWLINE# self . total_sockets -= num_culling #NEWLINE# return [ self . _remove_sock ( e [ 1 ] ) for e in culled ]