-
Notifications
You must be signed in to change notification settings - Fork 25
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
Observer or Change Event #26
Comments
Hi, I guess it depends a bit on your use case, but it's true, UltraDict is not an event library. With UltraDict, you could just use those configuration values where and when you need them and UltraDict would update them automatically in the background. You'd have to share more information on what kind of configuration, why and when it changes and what would kind of actions be in the callbacks. Best, Ronny |
Hi Ronny, well, let's describe a little more what I want to archive. I have python tool (let's call it process 1) that is controlling a network interfaces link quality (package loss, delay, bandwidth etc.) - it has an inbuilt command line interface for controlling the parameters. On the other hand I have a REST interface based on a flask project (that is process 2), that should also allow to change the link quality parameters via http. The link quality parameters are stored in the configuration which is shared via an UltraDict. So process 1 can read and change the values and will directly apply them, process 2 can only read and change the parameters. Now it would be nice for process 1 to get notified, if a value in the configuration changes, so that it can apply the change. Therefore a call back would be sufficient, as I only need to call the "UpdateLinkQuality" method. As the REST interface is only reading/writing the values in an event driven way it would not be necessary to get notified of any changes, as it rereads the value every time it gets a request. Due to design decisions the both interfaces should stay separated, so it is not an option to integrate the REST part directly into the tool. For the later use case I assume the values might sometimes change every 1-5 seconds, but most time they would not change for minutes or hours. |
Hey, I think in this case maybe look into using Pipes: https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Pipe They have a blocking |
Hi,
can you imagen of an easy way to subscribe to changes on the dictionary? Or of a way to extend the UltraDict to be able to subscribe for changes?
I have two processes sharing a configuration trough an UltraDict, but I would like to avoid polling the values every x seconds to ensure that both processes using the currently set configuration, if one of both changes some values. It would be nicer to have a callback function or something similar.
I am not a native python programmer, so maybe there are already other approaches for it in python, but I couldn't figure out something that I would assume could work in this scenario. What are your thoughts about that?
best regards,
ahorn
The text was updated successfully, but these errors were encountered: