-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
expose rx.get_state() to get instance of state from anywhere #3959
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit of a dangerous API, because if the state is modified, then that is essentially thrown away (unless in dev mode).
i think it would be better to expose a wrapper over app.modify_state
with an async contextmanager.
if we definitely want a get_state
that maybe skips taking a lock or sending an update or something, i think that's okay, but we should wrap it in a StateProxy like a background task so it cannot be modified outside of async with state:
I think it could have its use, mostly as a way to get a snapshot of the state at instant t (when the API request arrive for example) it's a part of this POC: #2819, stripped down for minimal changes. I do plan to also wrap / expose modify_state, but it'll be more complex because we need to solve the synchronicity problem between workers (above PR has a solution, but if redis is optional, I'm not sure it's applicable anymore)
|
When you do |
I see. Will have to brainstorm a bit on this to figure out the ideal way. |
small example sending state info related to a specific token through API