Skip to content
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

Message can be lost if the sender exits right after sending it #201

Open
enrico-samknows opened this issue Jan 18, 2023 · 0 comments
Open

Comments

@enrico-samknows
Copy link

Hello, I'm trying to write a program which publishes a single message, then quits.
By using strace, I can see a new child process is spawned, which does the sending part.
When I destroy the pub_socket the message is not sent yet. I also do io_context.run() and when it returns the message is not sent yet.
I also tried to let io_context go out of scope, but it doesn't force the message to be sent.
The only thing working for me is adding a sleep_for in the main thread. Then I see the message is sent with 100% success rate.

Is there a better way to "flush" the socket or to perform a "controlled close", so when it returns I can be 100% sure the message has been sent? I'm using an IPC transport, but I guess it's a common issue to all transports.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant