Threads vs Processes

Carl J. Van Arsdall cvanarsdall at mvista.com
Thu Jul 27 12:17:56 EDT 2006


bryanjugglercryptographer at yahoo.com wrote:
> Carl J. Van Arsdall wrote:
>   
>> Alright, based a on discussion on this mailing list, I've started to
>> wonder, why use threads vs processes.
>>     
>
> In many cases, you don't have a choice. If your Python program
> is to run other programs, the others get their own processes.
> There's no threads option on that.
>
> If multiple lines of execution need to share Python objects,
> then the standard Python distribution supports threads, while
> processes would require some heroic extension. Don't confuse
> sharing memory, which is now easy, with sharing Python
> objects, which is hard.
>
>   
Ah, alright, I think I understand, so threading works well for sharing 
python objects.  Would a scenario for this be something like a a job 
queue (say Queue.Queue) for example.  This is a situation in which each 
process/thread needs access to the Queue to get the next task it must 
work on.  Does that sound right?  Would the same apply to multiple 
threads needed access to a dictionary? list?

Now if you are just passing ints and strings around, use processes with 
some type of IPC, does that sound right as well?  Or does the term 
"shared memory" mean something more low-level like some bits that don't 
necessarily mean anything to python but might mean something to your 
application?

Sorry if you guys think i'm beating this to death, just really trying to 
get a firm grasp on what you are telling me and again, thanks for taking 
the time to explain all of this to me!

-carl


-- 

Carl J. Van Arsdall
cvanarsdall at mvista.com
Build and Release
MontaVista Software




More information about the Python-list mailing list