I have a multiprocess Pool that takes a little bit of time to complete. I would like print a message letting me know that the pool has stated, and on the same line, print "complete" when its done. Something like this "Pool has started its thing... complete."
For some reason, when I change the end=
to anything other than the default \n
, it will wait to print the whole message at the same time.
Code that acts weird:
print("Sanity print statement.")
print("Pool has started its thing...", end=' ')
with Pool(16) as pool:
var = pool.map(task, args)
print("complete.")
Output:
line 1: Sanity print statement.
# waits a few seconds
line 2: Pool has started its thing... complete.
Code that acts as expected:
print("Sanity print statement.")
print("Pool has started its thing...", end='\n')
with Pool(16) as pool:
var = pool.map(task, args)
print("complete.")
Output:
line 1: Sanity print statement.
line 2: Pool has started its thing...
# waits a few seconds
line 2: Pool has starte its thing... complete.
This was a little difficult to show the exact behavior of the output so I hope I made it clear enough.
And this is just me trying to understand. I know it can just be printed on the next line, but I need to be able to sleep at night knowing that computer's haven't started thinking for themselves.