Is print thread safe?
Steven D'Aprano
steve at pearwood.info
Mon Aug 11 03:44:17 EDT 2014
Specifically for Python 2.6 and 2.7, but answers for 3.x appreciated as
well.
Is print thread safe? That is, if I have two threads that each call
print, say:
print "spam spam spam" # thread 1
print "eggs eggs eggs" # thread 2
I don't care which line prints first, but I do care if the two lines are
mixed in together, something like this:
spam spaeggs eggs m seggspams
Does print perform its own locking to prevent this?
--
Steven
More information about the Python-list
mailing list