[Twisted-Python] oddness in gtk reactor compred to wx and plain reactor

David E. Konerding dekonerding at lbl.gov
Tue Feb 24 15:30:49 EST 2004


I have been experience a weird problem with the gtk reactor.  I've got a 
simple test case which seems to reproduce the problem, so I'm checking 
with the mailing list to understand if everything is going on properly.
Here's the test code.  I wasn't sure whether the log. calls are 
thread-safe, but I've noticed the same problem with
Python's logging package.  Using the wxPython or plain reactor seems to 
work as expected: messages from the TestThingy are spewed at about 
0.1/sec, while with gtk, messages only come every 2 seconds if at all.

import time, sys, logging

from twisted.internet import gtk2reactor

## from wxPython.wx import *
## from twisted.internet import wxsupport

from twisted.internet import reactor

from twisted.python import threadable

from twisted.python import log

from twisted.internet import app
from twisted.manhole import telnet
from twisted.application import strports

## For testing with wx reactor
## class myWxApp(wxApp):
##     def OnInit(self):
##         return True

## mywxAppInstance = myWxApp(0)
## wxsupport.install(mywxAppInstance)

class TestThingy:
    def __init__(self):
        log.err("TestThingy created")

    def run(self):
        log.err("TestThingy run")
        for i in range(10):
            log.err("TestThingy message")
        log.err("TestThingy done")
class ThingyManager:
    def __init__(self):
    def submitThingy(self):
        log.err("ThingyManager submitting")
        f = TestThingy()
        log.err("ThingyManager created")
        log.err("ThingyManager calledInThread")

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

t = ThingyManager()
log.err("Starting timer")
reactor.callLater(0, timer)
log.err("Submitting transfer")
reactor.callLater(3, t.submitThingy)
log.err("Running reactor")
## for starting the wx reactor
log.err("Reactor done")

More information about the Twisted-Python mailing list