I'm using Pool
under multiprocessing
to do some stuff.
def my_func(...):
#Different processes can take different time
print a, b, c #Value that I calculated above. (includes 2 new-lines)
There have been instances where values of a, b, c for a process are not printed together. Is there a way to avoid that? Can anyone explain as to what's happening here and how it can be avoided?
My understanding says that if I remove all newlines in the print and keep only one at the end, it should fix the problem. (Problem is, it's not reproducible every time so I'm still testing stuff).
Is there a way I can take sys.stdout
exclusively for a process and then release it while I'm printing stuff to STDOUT
?