Is the standard output thread-safe?
Skull
skullw at sina.com.cn
Sun Mar 12 05:23:58 EST 2006
Fernando Rodríguez <frr at easyjob.net> writes:
> Hi,
>
> Is the standard output thread-safe? Can I use print from several
> threads without having to use a mutex?
>
> Thanks
>
>
Check this: http://me.in-berlin.de/doc/python/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe
from my experience, it seems 'print' is not thread-safe. especially
when it is called with formated string, such as:
print "id:%d", my_id
I think it is not an "atomic" operation.
--
More information about the Python-list
mailing list