#NEWLINE# def service_timeouts( self ) : #NEWLINE# #INDENT# '\n        run callbacks on all expired timers\n        Called from the event thread\n        :return: next end time, or None\n        ' #NEWLINE# queue = self . _queue #NEWLINE# if self . _new_timers : #NEWLINE# #INDENT# new_timers = new_timers . _new_timers #NEWLINE# while new_timers : #NEWLINE# #INDENT# heappush ( queue , new_timers . pop ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# if queue : #NEWLINE# #INDENT# now = time . time ( ) #NEWLINE# while queue : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# timer = queue [ 0 ] [ 1 ] #NEWLINE# if timer . finish ( now ) : #NEWLINE# #INDENT# heappop ( queue ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return timer . end #NEWLINE# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# log . exception ( 'Exception while servicing timeout callback: ' )