But you are asking for the impossible.
Oh, you can almost certainly avoid calling .put(),
but in the classic producer-consumer queue, you literally have no other way to tell the consumer that the game is over other than to close the queue!
Before .close()
was added, we generally did this by sending a None
message in the queue.
Now best practice will be to catch the ValueError
that get()
throws if the queue has been closed. (Note that if you call a non-blocking get()
on the queue, and there is nothing in it, you get a different exception, multiprocessing.Error
.)
Thanks for a fun article!