[Twisted-Python] twisted gtk-reactor bug 552

David E. Konerding DSD Staff dekonerding at lbl.gov
Mon Apr 26 17:47:10 EDT 2004


Hi,

I'm checking in again to see if anybody had taken a look at my bug report,

http://www.twistedmatrix.com/users/roundup.twistd/twisted/issue552

I discussed it a little bit on a slow day on IRC, but nobody had any 
solutions.
However, it was reproduced on NetBSD-current w/ pygtk-2 and gtk-2.4, so I'm
pretty sure it's not specific to my location.

In summary:

I'm using the gtk2reactor, and periodically scheduled events (invoked 
via reactor.callLater->reactor.callInThread)
are not being fired in a timely fashion.  When I originally mentioned 
the bug on the mailing list, people thought
I was calling 'sleep' in the main (reactor) thread, but actually, sleep 
is only called in another thread, and
it works fine with the plain reactor and the wx reactor.

Here is the example program (you should see 'TestThingy message' every 
0.1 seconds or so..)
Note that the bug report has two lines improperly indented.

import time, sys

from twisted.internet import gtk2reactor
gtk2reactor.install()
from twisted.python import threadable
threadable.init()
from twisted.internet import reactor
from twisted.python import log
log.startLogging(sys.stdout)

class TestThingy:
 def __init__(self):
     print "TestThingy created"

 def run(self):
     print "TestThingy run"
     for i in range(10):
         print "TestThingy message"
         time.sleep(0.1)
     print "TestThingy done"

class ThingyManager:
 def __init__(self):
     pass

 def submitThingy(self):
     log.err("ThingyManager submitting")
     f = TestThingy()
     log.err("ThingyManager created")
     reactor.callInThread(f.run)
     log.err("ThingyManager calledInThread")

def ticker(*args):
 log.err("ticker: %d" % time.time())
 reactor.callLater(1, ticker)

t = ThingyManager()
reactor.callLater(0, ticker)
reactor.callLater(3, t.submitThingy)
reactor.run()
log.err("Reactor done")


Dave






More information about the Twisted-Python mailing list