[Python-Dev] Twisted Isn't Specific (was Re: Trial balloon: microthreads library in stdlib) (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Fri Feb 16 07:48:16 CET 2007
- Previous message: [Python-Dev] Twisted Isn't Specific (was Re: Trial balloon: microthreads library in stdlib)
- Next message: [Python-Dev] Twisted Isn't Specific (was Re: Trial balloon: microthreads library in stdlib)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
Speaking of which: Tcl has a "multiple interpreter" model where each interpreter is single-threaded. You can build Tcl either single- or multi-threaded; for the multi-threaded Tcl, you still can't share data across threads directly, but instead, you create an interpreter per thread. Then, all operations on that interpreter must occur in this thread, including the reactor calls.
So if the PerfectReactor is to support Tcl/Tk, it needs to run the Tcl even loop in the Tcl thread, which is normally the main thread (in Tkinter, it's the thread where you originally created the tkapp object). OTOH, PerfectReactor may also need to run some Win32 event loop in the same thread.
Regards, Martin
- Previous message: [Python-Dev] Twisted Isn't Specific (was Re: Trial balloon: microthreads library in stdlib)
- Next message: [Python-Dev] Twisted Isn't Specific (was Re: Trial balloon: microthreads library in stdlib)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]