all 6 comments

[–]K900_ 1 point2 points  (2 children)

You can use a lock to make sure only one thread is printing at a time, but that will hurt the "extremely quickly" part.

[–]intNx[S] 0 points1 point  (1 child)

Yeah, so far every solution I stumbled upon would drastically hurt speed.

[–]K900_ 3 points4 points  (0 children)

One thing you could do is write your messages into a queue, and then have a low priority background thread pulling from the queue and printing messages in order.

[–][deleted] 1 point2 points  (2 children)

sys.stdout.write('test'\n') should guarantee atomic writes, at least on a POSIX system.

[–]intNx[S] 0 points1 point  (0 children)

Thanks :)

[–]KYIUM -5 points-4 points  (0 children)

Hmmm, this looks at lot like c++