#NEWLINE# def cleanup( self ) : #NEWLINE# #INDENT# '\n\t\tReturns two lists in a tuple where the first list is any sheep who timed\n\t\tout due to bleets (lost sheep), and the second list is any sheep that\n\t\ttimed out while servicing a request (killed sheep).\n\n\t\tAny lost sheep will simply be forgotten about, any killed sheep will\n\t\thave the test request they were servicing placed back into the request\n\t\tqueue than they will be forgotten about as well.\n\n\t\t' #NEWLINE# lost_sheep = [ ] #NEWLINE# killed_sheep = [ ] #NEWLINE# if self . bleet_timeout : #NEWLINE# #INDENT# while ( self . _bleet_queue and ( self . _bleet_queue . smallest ( ) . priority < ( datetime . datetime . now ( ) - self . bleet_timeout ) ) ) : #NEWLINE# #INDENT# lost_sheep . append ( self . _bleet_queue . pop_smallest ( ) . value ) #NEWLINE# #UNINDENT# #UNINDENT# if self . service_timeout : #NEWLINE# #INDENT# while ( self . _service_queue and ( self . _service_queue . smallest ( ) . priority < ( datetime . datetime . now ( ) - self . service_timeout ) ) ) : #NEWLINE# #INDENT# killed_sheep . append ( self . _service_queue . pop_smallest ( ) . value ) #NEWLINE# #UNINDENT# #UNINDENT# for i in lost_sheep : #NEWLINE# #INDENT# self . remove_sheep ( i ) #NEWLINE# #UNINDENT# for i in killed_sheep : #NEWLINE# #INDENT# self . remove_sheep ( i ) #NEWLINE# #UNINDENT# return ( lost_sheep , killed_sheep )