Multiple scripts versus single multi-threaded script

Roy Smith roy at panix.com
Thu Oct 3 15:53:38 EDT 2013


In article <mailman.691.1380825390.18130.python-list at python.org>,
 Chris Angelico <rosuav at gmail.com> wrote:

> As to your corrupt data example, though, I'd advocate a very simple
> system of object ownership: as soon as the object has been put on the
> queue, it's "owned" by the recipient and shouldn't be mutated by
> anyone else.

Well, sure.  I agree with you that threading in Python is about a 
zillion times easier to manage than threading in C/C++, but there are 
still things you need to think about when using threading in Python 
which you don't need to think about if you're not using threading at 
all.  Transfer of ownership when you put something on a queue is one of 
those things.

So, I think my original statement:

> if you're looking for a short answer, I'd say just keep doing what 
> you're doing using multiple processes and don't get into threading.

is still good advice for somebody who isn't sure they need threads.

On the other hand, for somebody who is interested in learning about 
threads, Python is a great platform to learn because you get to 
experiment with the basic high-level concepts without getting bogged 
down in pthreads minutiae.  And, as Chris pointed out, if you get it 
wrong, at least you've still got valid Python objects to puzzle over, 
not a smoking pile of bits on the floor.



More information about the Python-list mailing list