#NEWLINE# def run( self ) : #NEWLINE# #INDENT# 'Event loop scheduled on the designated event loop thread. The loop is\n        suspended/resumed using the event which gets set by calls to Schedule,\n        the next item timer, or calls to dispose.' #NEWLINE# while True : #NEWLINE# #INDENT# ready = [ ] #NEWLINE# with self . condition : #NEWLINE# #INDENT# if self . is_disposed : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# while ( len ( self . queue ) and ( self . queue . peek ( ) . duetime <= self . now ( ) ) ) : #NEWLINE# #INDENT# item = self . queue . dequeue ( ) #NEWLINE# self . ready_list . append ( item ) #NEWLINE# #UNINDENT# if len ( self . queue ) : #NEWLINE# #INDENT# _next = self . queue . peek ( ) #NEWLINE# if ( ( self . next_item is None ) or ( _next != self . next_item ) ) : #NEWLINE# #INDENT# self . next_item = _next #NEWLINE# due = ( _next . duetime - self . now ( ) ) #NEWLINE# seconds = due . total_seconds ( ) #NEWLINE# log . debug ( 'timeout: %s' , seconds ) #NEWLINE# self . timer = Timer ( seconds , self . tick , args = ( _next , ) ) #NEWLINE# self . timer . setDaemon ( True ) #NEWLINE# self . timer . start ( ) #NEWLINE# #UNINDENT# #UNINDENT# if len ( self . ready_list ) : #NEWLINE# #INDENT# ready = self . ready_list [ : ] #NEWLINE# self . ready_list = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . condition . wait ( ) #NEWLINE# #UNINDENT# #UNINDENT# for item in ready : #NEWLINE# #INDENT# if ( not item . is_cancelled ( ) ) : #NEWLINE# #INDENT# item . invoke ( ) #NEWLINE# #UNINDENT# #UNINDENT# if self . exit_if_empty : #NEWLINE# #INDENT# with self . condition : #NEWLINE# #INDENT# if ( ( not len ( self . ready_list ) ) and ( not len ( self . queue ) ) ) : #NEWLINE# #INDENT# self . thread = None #NEWLINE# return