I do:
import multiprocessing as mp
q = mp.Queue()
p = mp.Process(target=lambda x: x, args=('foo',))
p.start()
p.join(10)
if p.exitcode == 0:
q.get()
else:
print("We timed out.")
What I expect is that my tiny x->x function will block for at most 10 seconds. If it finished before then, I get the result sooner than that. If it takes longer than that (obviously not in this toy example, but in other cases), then the process terminates after 10 seconds and I am able to check exitcode to determine that we have indeed timed out.
But when I execute this code, what happens instead is that q.get() runs forever. Why does this occur?