[Tutor] threading vs. forking?

Jeff Shannon jeff@ccvcorp.com
Fri Jul 11 13:28:01 2003


Rodrigues wrote:

>>[mailto:tutor-admin@python.org]On Behalf Of
>>Thomas CLive Richards
>>
>>with "main" and "child" threads, am i correct when i say that if you
>>only have two threads (a min and a child thread), you only
>>actually need
>>to create the child thread, and the main thread is just run
>>as the rest
>>of the program? (kind of like how it's done with forking)?
>>    
>>
>Yes, you are correct. For a given process there is always one thread,
>the main thread. This thread could be the Gui thread. 
>

Indeed, if you're using wxPython for your GUI (as you mentioned that you 
were, previously), then your main thread *must* be your GUI thread -- 
wxPython does quite a bit of setup when it's first imported, and the GUI 
must run from the thread in which that initial import occurs.  (It's 
possible to coerce it to run in a secondary thread, by ensuring that no 
imports of wxPython happen until after that thread starts, but it's 
definitely an exercise in coercion -- it's not something you'd want to 
do without exceptional circumstances dictating it.)

Jeff Shannon
Technician/Programmer
Credit International