Skip to content
Browse files

timer events needed more management

  • Loading branch information...
1 parent 4220f4a commit 76d7e16dcdb8845448fff9002ac1f6f5a175e048 @ghtdak committed Mar 10, 2008
Showing with 9 additions and 18 deletions.
  1. +9 −18 qt4reactor.py
View
27 qt4reactor.py
@@ -172,13 +172,13 @@ def crash(self):
super(QTReactor,self).crash()
def cleanup(self):
- #self.iterate(0.1) # cleanup pending events?
- self.running=False
- self.qApp.emit(SIGNAL("twistedEvent"),'shutdown')
+ self._timer.stop()
+ self._blockApp.quit()
def iterate(self,delay=0.0):
endTime = delay + time.time()
- self._timer.start(0) # locked?
+ if not self._timer.isActive():
+ self._timer.start(0) # locked?
self.qApp.processEvents() # gotta do at least one
while True:
t = endTime - time.time()
@@ -199,8 +199,6 @@ def runReturn(self, installSignalHandlers=True):
self.addSystemEventTrigger('after', 'shutdown', self.cleanup)
self.addSystemEventTrigger('before', 'shutdown',
self.reactorInvocation)
- self.qApp.emit(SIGNAL("twistedEvent"),'startup')
- QTimer.singleShot(101,self.slowPoll)
self._timer.start(0)
def run(self, installSignalHandlers=True):
@@ -214,26 +212,19 @@ def run(self, installSignalHandlers=True):
finally:
self._blockApp=None
- def slowPoll(self):
- self.qApp.emit(SIGNAL("twistedEvent"),'slowpoll')
- if self.running:
- QTimer.singleShot(101,self.slowPoll)
-
def reactorInvocation(self):
self._timer.setInterval(0)
def reactorInvokePrivate(self):
self._doSomethingCount += 1
if self.running:
self.runUntilCurrent()
- self.qApp.processEvents() # hmmmm
- t2 = self.timeout()
- t = self.running and t2
- if t is None: t=1.0
+ t = self.timeout()
+ if not self.running:
+ self.qApp.processEvents()
+ return
+ elif t is None: t=0.1
self._timer.start(t*1010)
- else:
- if self._blockApp is not None:
- self._blockApp.quit()
def doIteration(self):
assert False, "doiteration is invalid call"

0 comments on commit 76d7e16

Please sign in to comment.
Something went wrong with that request. Please try again.