[Python-Dev] Twisted Isn't Specific (was Re: Trial balloon: microthreads library in stdlib)

Josiah Carlson jcarlson at uci.edu
Fri Feb 16 08:45:25 CET 2007


"Martin v. Löwis" <martin at v.loewis.de> wrote:
> 
> Larry Hastings schrieb:
> > Oof!  I'm embarrassed to have forgotten that.  But that's not a fatal 
> > problem.  It means that on Windows the PerfectReactor must service the 
> > blocking GetMessage loop, and these other threads notify the 
> > PerfectReactor of new events by sending a message. 
> ...
> > I'd be interested to hear about other situations where threading would 
> > cause a problem.  My suspicion is that Windows is the hard one, and as 
> > I've shown that one is solvable.
> 
> As others have reported: if you have a gtk reactor and a wx reactor
> to support, in addition to a "regular" Win32 reactor (e.g. PythonWin),
> your approach still won't work. They all do GetMessage behind the
> scenes (sp?), yet you would run them in multiple threads, so they
> get their own messages. Plus they are not thread-safe.

At least on the wx side of things, there exist ways of scheduling calls
to be executed inside its event dispatching loop (wx.CallAfter,
wx.FutureCall, wx.PostEvent), which allows for worker threads to hand
data back to the main thread (the creator of the wx.App instance, like
Tk). I would be surprised if the other toolkits didn't have something
similar, couldn't be manipulated into using Queues to communicate in
some way, or couldn't be manipulated into directly sending a message on
win32.


 - Josiah



More information about the Python-Dev mailing list