[Twisted-Python] wxPython locking the event processing?
Uwe C. Schroeder
uwe at oss4u.com
Sat Jul 5 14:00:19 MDT 2003
On Saturday 05 July 2003 11:48 am, Patrik Blommaskog wrote:
> > -----Original Message-----
> > From: twisted-python-admin at twistedmatrix.com
> > [mailto:twisted-python-admin at twistedmatrix.com]On Behalf Of Uwe C.
> > Schroeder
> > Sent: den 5 juli 2003 19:57
> > To: twisted-python at twistedmatrix.com
> > Subject: Re: [Twisted-Python] wxPython locking the event processing?
> >
> > On Saturday 05 July 2003 10:14 am, Itamar Shtull-Trauring wrote:
> > > On Sat, 5 Jul 2003 18:24:49 +0200
> > >
> > > "Patrik Blommaskog" <pb_twisted at olga.mine.nu> wrote:
> > > > Meanwhile, is there anything that I should be aware of considering
> > > > that we now have separate threads for wx and Twisted? Can I for
> > > > example use reactor.callLater() to call methods on wx objects, or
> > > > work with Perspectives, Cacheables, reactor etc from wx event
> > > > handlers without any problems?
> > >
> > > They will break horribly. So, use reactor.callFromThread to call
> > > twisted APIs from wx thread
>
> Good, that's what I did already. :)
>
> So if I understand it correctly, at least reactor.callFromThread (and
> callLater?) are thread safe in this case?
>
> > > and the wx equivalent to call wx APIs from the
> > > twisted thread.
> >
> > The wx equivalent should be wx.CallAfter, which will schedule the given
> > function in the (wx) mainthread.
>
> Thanks!
>
> > Even if you decide to use the unthreaded
> > recipe I posted on activestate, you will still have to call wx
> > functions from outside a twisted callback.
>
> I'm not sure I understand. Do you mean that a reactor.callFromThread won't
> do to, say, insert text into a text control, and I should use wx.CallAfter
> instead, even in your unthreaded recipe?
Depends on what you call. You can set field values. Basically you can call
anything from a callback that doesn't block. So don't open any modal dialogs
from a callback. Otherwise setting/getting values etc. works.
Whenever you experience a block, check the callbacks first to see if you're
opening something that blocks.
I.e. I use error callbacks that open an error message dialog. This will block
the loop until you close the dialog. In this case the error message dialog is
fine, since I don't care if it blocks - it's an error anyways, so the user
has to click it away to continue. Not so with a - say "settings" dialog. The
user would want to do input there and that won't work. Therefor whenever I
have to open a modal dialog from a callback, I create a second method for
that and use wx.CallAfter.
>
> - Patrik
>
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
--
UC
--
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417
More information about the Twisted-Python
mailing list