In article <[EMAIL PROTECTED]>, Adrian Casey <[EMAIL PROTECTED]> wrote: >Aahz wrote: >> In article <[EMAIL PROTECTED]>, >> Frans Englich <[EMAIL PROTECTED]> 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 ([EMAIL PROTECTED]) <*> 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 -- http://mail.python.org/mailman/listinfo/python-list