#NEWLINE# def run( self , end_time ) : #NEWLINE# #INDENT# 'Schedule and display events until time is up' #NEWLINE# for ( _ , proc ) in sorted ( self . procs . items ( ) ) : #NEWLINE# #INDENT# first_event = next ( proc ) #NEWLINE# self . events . put ( first_event ) #NEWLINE# #UNINDENT# time = 0 #NEWLINE# while ( time < end_time ) : #NEWLINE# #INDENT# if self . events . empty ( ) : #NEWLINE# #INDENT# print ( '*** end of events ***' ) #NEWLINE# break #NEWLINE# #UNINDENT# current_event = self . events . get ( ) #NEWLINE# print ( 'taxi:' , current_event . proc , ( current_event . proc * '   ' ) , current_event ) #NEWLINE# time = current_event . time #NEWLINE# proc = self . procs [ current_event . proc ] #NEWLINE# try : #NEWLINE# #INDENT# next_event = proc . send ( time ) #NEWLINE# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# del self . procs [ current_event . proc ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . events . put ( next_event ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# msg = '*** end of simulation time: {} events pending ***' #NEWLINE# print ( msg . format ( self . events . qsize ( ) ) )