How to handle per-user network resources in a Reflex app #3829
scottpersinger
announced in
General
Replies: 1 comment
-
You could use a rx.background task triggered by on_load. You'll need an async mqtt client for this to work |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Can anyone suggest a good pattern for managing network-listening resources on a per session basis?
I want to have a separate Redis pubsub connection for each Reflex session. But I can't put the Redis connection inside the app state because it's not serializable. I had been storing at module level, but that means the connections aren't per-session.
My current plan is to override the serialization so that I can include the Redis conn in the state, but I will serialize it in some benign form and then hopefully try to "reconnect" it on the other side of the state replication. But I'm open to a better suggestion...
I suppose I could keep my own session->connection dictionary at module level, and index into it with the current Rx session id...
Beta Was this translation helpful? Give feedback.
All reactions