def doIteration(self, delay):
# flush some pending events, return if there was something to do
# don't use the usual "while gtk.events_pending(): mainiteration()"
# idiom because lots of IO (in particular test_tcp's
# ProperlyCloseFilesTestCase) can keep us from ever exiting.
log.msg(channel='system', event='iteration', reactor=self)
if gtk.events_pending():
gtk.mainiteration(0)
return
# nothing to do, must delay
if delay == 0:
return # shouldn't delay, so just return
self.doIterationTimer = gtk.timeout_add(int(delay * 1000),
self.doIterationTimeout)
# This will either wake up from IO or from a timeout.
gtk.mainiteration(1) # block
# note: with the .simulate timer below, delays > 0.1 will always be
# woken up by the .simulate timer
if self.doIterationTimer:
# if woken by IO, need to cancel the timer
gtk.timeout_remove(self.doIterationTimer)
self.doIterationTimer = None
评论列表
文章目录