Kill GIL

Aahz aahz at pythoncraft.com
Tue Feb 15 11:29:14 EST 2005


In article <4211e287 at duster.adelaide.on.net>,
Adrian Casey  <news at outbacklinux.com> wrote:
>Aahz wrote:
>> In article <mailman.2502.1108343142.22381.python-list at python.org>,
>> Frans Englich  <frans.englich at telia.com> wrote:
>>>
>>>Personally I need a solution which touches this discussion. I need to run
>>>multiple processes, which I communicate with via stdin/out,
>>>simultaneously, and my plan was to do this with threads. Any favorite
>>>document pointers, common traps, or something else which could be good to
>>>know?
>> 
>> Threads and forks tend to be problematic.  This is one case I'd recommend
>> against threads.
>
>Multiple threads interacting with stdin/stdout?  I've done it with 2
>queues.  One for feeding the threads input and one for them to use
>for output.  In fact, using queues takes care of the serialization
>problems generally associated with many threads trying to access a
>single resource (e.g. stdout).  Python Queues are thread-safe so you
>don't have to worry about such issues.

The problem is that each sub-process really needs its own stdin/stdout.
Also, to repeat, forking tends to be problematic with threads.  Finally,
as Peter implied, I'm well-known on c.l.py for responding to thread
problems with, "Really?  Are you using Queue?  Why not?"  However, this
is one case where Queue can't help.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR



More information about the Python-list mailing list