[Python-Dev] Threading in the Standard Library Tour Part II (original) (raw)
Bob Ippolito bob at redivi.com
Mon Aug 16 17:44:37 CEST 2004
- Previous message: [Python-Dev] Threading in the Standard Library Tour Part II
- Next message: [Python-Dev] Threading in the Standard Library Tour Part II
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Aug 16, 2004, at 11:31 AM, Anthony Baxter wrote:
Bob Ippolito wrote:
Maybe I don't understand what you're saying.. but I don't know any platform that forces you to work with files from one and only one specific thread. But I definitely do know at least one platform where you may only perform most GUI operations from the main thread of execution. There's a number of GUIs in this boat. It's not too much hassle - you just have to make sure you handle events to and from the GUI correctly through some sort of intermediary that posts the events to the correct thread. An example of this is wx and twisted - the only sane path is to run each in it's own thread. wx also won't work unless the "main" thread is the one running the GUI.
But in those cases, Twisted only needs the mainloop to do two things: fire timers, watch file descriptors. It's possible to write a reactor for many or most GUIs that does that while still remaining single threaded (as far as Python is concerned). For GUIs that don't natively "watch sockets" as part of their runloop, you can start a thread that does that and only that and send asynchronous notifications to the GUI mainloop (which is what Cocoa/CoreFoundation does behind your back with their networking APIs).
-bob
- Previous message: [Python-Dev] Threading in the Standard Library Tour Part II
- Next message: [Python-Dev] Threading in the Standard Library Tour Part II
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]