[Twisted-Python] how manual run LoopingCall.f

ploutosss ploutosss ploutosss at gmail.com
Mon Dec 28 08:05:05 EST 2009

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()
                yield eventmodule.wait()
    def run(self):
        for event in self._eventIterator():
            if event.type == NOEVENT:
            elif event.type == TWISTEDEVENT:
                if not reactor.running:
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:

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__
  File "/usr/lib64/python2.6/site-packages/twisted/internet/defer.py",
line 199, in addErrback
  File "/usr/lib64/python2.6/site-packages/twisted/internet/defer.py",
line 181, in addCallbacks
--- <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
exceptions.AttributeError: 'NoneType' object has no attribute 'errback'

More information about the Twisted-Python mailing list