wxreactor [was Re: [Twisted-Python] Silencing PotentialZombieWarning]

Stephen Waterbury stephen.c.waterbury at nasa.gov
Thu Nov 6 16:30:34 EST 2008

Reza Lotun wrote:
> I'm working on a multi-platform (win32 and os x) wx + Twisted app,
> where I've found the best solution is to run both in a separate thread
> - the main thread is wx, and the other is Twisted. It basically works
> like a charm (though I'd be interested in hearing about other
> approaches. I've also played with wxreactor way back, but didn't find
> it as stable).

I'd be interested to know what wxreactor symptoms of non-stability
you saw.

A few months ago, the wxreactor apps wxdemo.py and wxacceptance.py on
ubuntu worked, but if I added a file dialog to wxacceptance.py, invoking
the file dialog caused the application to hang.

In my most recent experiments, wxdemo.py just hangs but
wxacceptance.py works fine, even with the addition of a file dialog
-- presumably due to some recent change in wx, since wxreactor has not
been modified recently.  The environment I'm using is:

* ubuntu hardy, fully updated
* Python 2.5.2
* wxPython (python-wxgtk2.8 from http://apt.wxwidgets.org/)
* Twisted svn trunk rev 25323.

I've attached an example (wxacceptancemod.py) that has the
file dialog that used to cause the lock-up, sets the helloWorld loop
interval to 4 seconds, and closes the gui window immediately when
it receives the DoExit event (by calling self.Show(False)) --
a friendlier behavior than the original wxacceptance.py, which
leaves the gui window hanging until the last reactor iteration
completes (kinda misses the point of being asynchronous ;),
although this only becomes noticeable if the helloWorld loop interval
is set to more than a second or two.

Interestingly, wxdemo.py works if the helloWorld loop from
wxacceptance.py is added to it, and wxacceptance.py ceases to work
if the callLater loop is removed.  The looping interval used is
arbitrary, so it seems the reactor stack needs to stay loaded with 
something or it hangs.

Although it's not pretty, I don't mind adding a non-printing callLater
loop to my code so that wxreactor works, but of course it would be
nice to know what's going on. ;)

Do others see these behaviors if you run these examples?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wxacceptancemod.py
Type: text/x-python
Size: 3619 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20081106/d6988e4a/attachment.py 

More information about the Twisted-Python mailing list