print in multithreaded environement ???

Aahz aahz at pythoncraft.com
Thu Feb 26 16:39:27 EST 2004


In article <5c184570.0402250756.1715ee17 at posting.google.com>,
vincent delft <vincent_delft at yahoo.com> wrote:
>
>What will be the result if I have several threads that print to
>different buffers ?

What do you mean by "buffer"?  Different file handles?

>I have several threads, each one execute different python code. 
>Just before the "exec" of this small python code, I redirect the
>output to a "buffer".
>Each thread has his own buffer.
>What will be the result when they print at the same time ?

If the buffer is a simple string that you're printing, the order in
which buffers are output is non-determinate (absent explicit ordering
through the use of Queue.Queue or equivalent), but the entire string
will be output as a single chunk.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python



More information about the Python-list mailing list