I want to read a updated log file and update my Graph component in real time. If I just use “n_intervals” component, this means that the callback function must be run each time, the log file is loaded and the data is read
repeatedly. What’s more each update will change the zoom setting of Graph component
I know some examples that update the Graph in the Dash Tutorial and “extendData” keyword. But these example just add the given data (like a list of data given globally) to the Graph which is different from the real case reading from a log file.
So I want to use a Python generator according to the comments as https://stackoverflow.com/questions/5419888/reading-from-a-frequently-updated-file to just read the updated part of log file. But it’s hard to design a way to realize it.
There are some challenges:
- obviously we can not put the python generator in the updated callback function (because the callback function will be executed repeatedly and the “open” function in a generator will be executed repeatedly and the file will be closed after each “callback” function is closed. It will cause the generator not working)
- when write the generator in “main” function, the file path will be chosen in layout, I don’t know how to get the chosen “drop down” information in the main function.
I hope your help