[issue32902] FileInput "inplace" redirects output of other threads

Irit Katriel report at bugs.python.org
Mon Oct 5 19:01:11 EDT 2020


Irit Katriel <iritkatriel at yahoo.com> added the comment:

stdout is indeed shared between all threads, and it is also not guaranteed to be thread safe, so if two threads write to it simultaneously that can cause problems.

It is better to have one thread in you program writing to stdout, with thread-safe communication channels from other threads to this one.

Alternatively, you can create different processes instead of threads, and then each process will have its own stdout and redirecting one will not impact the others.

----------
nosy: +iritkatriel

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32902>
_______________________________________


More information about the Python-bugs-list mailing list