[Twisted-Python] Foreign event loop friendly reactor
Shawn Church
Sl_Church at sbcglobal.net
Sun Apr 17 16:21:36 MDT 2005
Thanks for your work in developing this new reactor. I just have a
couple questions:
Is it (thread) safe to call wx methods from within call/errbacks with
this reactor? I ask because I was (based upon the example at
http://solipsis.netofpeers.net/wiki/wikka.php?wakka=WxTwistedExample)
translating callbacks into wx.Events executed during the next wx loop
(the PostEvent function is thread safe). If I am understanding the
threadedselectreactor.py code correctly it is "waking" the wx loop and
therefore this should not be needed since only one mainloop will be
active at a time.
Also my understanding is that the reactor.interleave function should be
called ONCE in order to provide a function to wake the foreign event
loop. I am doing this in MyApp.OnInit() and it seems to work fine. The
example shows this being executed in the frame's __init__ function and I
do not think this will work for multiple frames (I'm not saying there is
anything WRONG with the example, I'm just trying to make sure I
understand the correct use of the new reactor when dealing with multiple
wxWindow objects).
I did not have any problems converting my test application to use the
new reactor, but I wanted to clarify these items so they don't bite me
later on.
Thanks once again,
Shawn
sl_church at sbcglobal.net
http://SChurchComputers.com
Bob Ippolito wrote:
> In response to the "wxpython issues" thread I had suggested that we
> should have a thread-using reactor that integrates with foreign event
> loops, so I wrote one and committed it
> (twisted.internet.threadedselectreactor). Since this approach
> requires less maintenance, and whomever maintains the select reactor
> can trivially maintain this as well, I'm "officially" deprecating
> cfreactor (although I never really cared much to maintain it anyway).
>
> An example of using it to integrate with a foreign event loop is at:
> doc/core/examples/Cocoa/SimpleWebClient
>
> It should be relatively trivial to show how it could be used to
> integrate with other event loops (wx, Tkinter, pygame, etc.).
> Effectively, it's compatible with anything that has a thread-safe way
> to notify the main event loop.
>
> In the future, it might make sense to revise the reactor API to
> support "interleave" directly, and change the existing reactors
> accordingly so that more than just select can support this behavior.
>
> -bob
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
More information about the Twisted-Python
mailing list