I just looked at an example for queues at Ray Docs. If you would use Queues like this with multiprocessing in Python it could deadlock, since another Process could empty the Queue after this process has checked if it is empty or not.
Can somebody please explain how it is different in Ray.
Ray’s semantics will follow exactly the multiprocessing.Queue’s semantics. Namely, if you only have one item in the queue and two callers calling queue.get(block=True), one of them will wait forever. Under the hood, Ray hosts a asyncio.Queue in a Ray actor.
Okay, it seems @Nemo is right and the example will reliably produce deadlock (especially since we say the example is for many consumers). It seems that we should rewrite the example to use queue.get(block=True, timeout=5) so that there isn’t this race condition.
Thoughts @simon-mo@sangcho ? I’m happy to create a fix for this (or @Nemo you can if you want, good find )