Multi-threaded printing and IOErrors in Windows

Roger Binns rogerb at rogerbinns.com
Fri Apr 23 05:34:55 EDT 2004


David Fraser wrote:
> sys.stdout is not threadsafe - try wrapping each call with a mutext and
> see if that fixes it...

Having to wrap hundreds of random print statements just using for
debugging seems really silly.  Note that I don't care if the
output gets garbled.  (It doesn't on Mac or Linux ever).

And I am only hitting this problem on Windows when wrapped
with py2exe.  If running outside of py2exe there is never
any problem.

When using py2exe, the stdout doesn't go anywhere anyway
(it is gui app not a console app).

The bizarre thing is that the IOError is very infrequent,
but very annoying when it happens.

Roger





More information about the Python-list mailing list