Is print thread safe?
Chris Angelico
rosuav at gmail.com
Mon Aug 11 20:14:29 EDT 2014
On Tue, Aug 12, 2014 at 9:56 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> from __future__ import print_function
>
> _print = print
> _rlock = threading.RLock()
> def print(*args, **kwargs):
> with _rlock:
> _print(*args, **kwargs)
You're conflating print and stdout here. Do you know which one is the
cause of your problems? Alternatively, can you be certain that you
never use either without the other?
ChrisA
More information about the Python-list
mailing list