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

Option for blocking publish #49

Open
AgDude opened this issue May 1, 2020 · 4 comments
Open

Option for blocking publish #49

AgDude opened this issue May 1, 2020 · 4 comments

Comments

@AgDude
Copy link

AgDude commented May 1, 2020

Feature request: Support for the "blocking" option from django_grip in eventstream.

Rationale:
We are running into an issue where some messages are not sent from celery workers. I suspect what is happening is that the celery worker process is exiting (including daemon threads) before the event is published by the daemon thread in pubcontrol.

We have logging in place just before calling eventstream.send_event, and the call is being made by the celery workers, but the message is not received by the client. This is a intermittent problem. We observed this with a self-hosted pushpin proxy, and continue to see this using fanout.io.

@AgDude
Copy link
Author

AgDude commented May 1, 2020

Clarification of python methods:

in django_grip the publish function accepts blocking as an argument. django-eventstream does not provide a means to set that argument, always falling back to the default of False.

@AgDude
Copy link
Author

AgDude commented May 1, 2020

Perhaps a good model would be to send arbitrary **kwargs, as I can think of use cases for a callback as well.

@jkarneges
Copy link
Member

Interesting. There's an atexit handler in pubcontrol to ensure messages get flushed, but possibly that doesn't work in all situations. Being able to do a blocking send seems reasonable. I've committed something for that.

However, I just realized this may not be needed because you can manually invoke the same waiting effect as the atexit handler like this:

from django_grip import get_pubcontrol

send_event(...)
get_pubcontrol().wait_all_sent()

Let me know if that works.

@AgDude
Copy link
Author

AgDude commented May 1, 2020

Thanks for the reply. Yes, that looks like it should do what I want. I will try it out.
I would expect the atexit handling to work as well.

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

2 participants