-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SYNC PUB-SUB dropping messages? #358
Comments
Yeah, I do not think the sleep matters here. I think you should be able to reproduce it if you set The fact that one of the subscribers may not be getting the first message is expected in a PUB-SUB pattern (asynchronous communication). The subscription is not guaranteed to happen immediately. So there is a chance the I think the fact that the second agent is always the one missing the message is because the first one had a little bit more time to subscribe, while the second has less time. But they both could be missing the first message, or even more. It is just about timing. If my theory is correct, you should be unable to reproduce if you do something like: time.sleep(0.1)
self.send('main', 'Hello world')
time.sleep(0.1) Note the delay before sending the message. Probably Anyway, that should not be a reason to hang... That is what I am unable to reproduce. Can you confirm the code is hanging under Linux? If so, which distribution? Is it virtualized or is it WSL? |
I understand it's an asynchronous communication pattern and you may not receive all the messages, but don't you think the above code should work? I would expect the call to In any case, having to insert manual sleeps after connecting only to make sure you get the messages looks weird. Maybe there should be some kind of mechanism inside to ensure the agent is actually listening, don't you think? |
By the way, this code never hangs, sorry for the misunderstanding, I was referring to the example from #357 instead. In that case, the parent agent would wait for both of its children to respond, but since one of them didn't get the first message, it would never do it and the parent would wait forever. Maybe "hangs" is a confusing word, should've said it runs into a deadlock or something. |
@ocaballeror Yeah, the subscription process is asynchronous too. That means, ZMQ will execute the subscription asynchronously when you We could add some code in osBrain, but I think that may be a bit application-specific. Although with the SYNC_PUB pattern it may be not that hard:
We could, at least, add an example and a note in the documentation explaining how to deal with this. If it is clean and general enough we could consider adding it to the base osBrain code too. |
Continuing the discussion from #357
Consider the following code:
I tried extending the
sleep
time up to 10 seconds to give the message a little bit more time to be sent, but it didn't work, sometimes the subscriber doesn't ever get the message. Here are some weird things I noticed that I can't find an explanation for:I am still confused 😕
The text was updated successfully, but these errors were encountered: