
I use _threadedselect reactor. My waker its one line: eventmodule.post(eventmodule.Event(TWISTEDEVENT, iterateTwisted=func)) its send event, to pygame queue. My pygame loop: class PygameController(object): _tick = Tick() def _eventIterator(self): while True: if self._ticking: yield eventmodule.poll() else: yield eventmodule.wait() def run(self): for event in self._eventIterator(): if event.type == NOEVENT: self.manager.post(self._tick) continue elif event.type == TWISTEDEVENT: event.iterateTwisted() if not reactor.running: break continue ... When I need to quickly perform some function, I set the parameter PygameController._ticking to True, and my manager call some function. Its work. When I need to perform some function with a time interval of more than one second, I use LoopingCall. Its work. When I need to perform some function with a time interval of less than one second, LoopingCall too slow. I try use my ticking, but for function is not executed too often, I used the following code:
def some_function(self): looping_instance = self.looping call = looping_instance.call if call and call.time - call.seconds() <= 0: looping_instance()
but I get this traceback when I stop looping (LoopingCall.stop()): File "/usr/lib64/python2.6/site-packages/twisted/internet/base.py", line 779, in runUntilCurrent call.func(*call.args, **call.kw) File "/usr/lib64/python2.6/site-packages/twisted/internet/task.py", line 196, in __call__ d.addErrback(eb) File "/usr/lib64/python2.6/site-packages/twisted/internet/defer.py", line 199, in addErrback errbackKeywords=kw) File "/usr/lib64/python2.6/site-packages/twisted/internet/defer.py", line 181, in addCallbacks self._runCallbacks() --- <exception caught here> --- File "/usr/lib64/python2.6/site-packages/twisted/internet/defer.py", line 323, in _runCallbacks self.result = callback(self.result, *args, **kw) File "/usr/lib64/python2.6/site-packages/twisted/internet/task.py", line 191, in eb d.errback(failure) exceptions.AttributeError: 'NoneType' object has no attribute 'errback'