Hi all,
I’ve a python script that is triggered every minutes and it generates a few graphs from grafana in PNG format.
These graphs are placed in the conf/html folder and are displayed in the basic ui.
The script first generates the graphs with temporary names and after rendering all graphs it replaces the old ones by removing them and renaming the new ones.
The problem is that it looks like openhab is keeping these image files open for several minutes. In this case the replacing of the new graphs fails since the python script can’t remove the old one since it is still in use by openhab.
This problem does not happen all the time. It looks like the files are released after a few minutes.
I’m using openhab on a windows system and I’m using build 1070.
See a screenshot of the handles in ProcessExplorer (open for multiple minutes):
An example of the definitions in my sitemap for the images:
Frame label="Vloerverwarming (Circuit 2)" {
Image url="http://localhost:8080/static/Graphs/HeatingFloorHeating.png" refresh=150000
}
Error in openhab logs:
2017-11-03 09:00:46.469 [INFO ] [marthome.model.script.GenerateGraphs] - Generated graphs.
2017-11-03 09:05:43.909 [INFO ] [marthome.model.script.GenerateGraphs] - Generated graphs.
2017-11-03 09:10:43.532 [INFO ] [marthome.model.script.GenerateGraphs] - Generated graphs.
2017-11-03 09:15:44.374 [INFO ] [marthome.model.script.GenerateGraphs] - Generated graphs.
2017-11-03 09:15:44.374 [INFO ] [rthome.model.script.GenerateGraphs] - Traceback (most recent call last):
File "C:\OpenHAB\conf\html\Graphs\GenerateGraphs.py", line 35, in <module>
os.remove(existing)
WindowsError: [Error 5] Access is denied: 'C:\\OpenHAB\\conf\\html\\Graphs\\HeatingFloorHeating.png'
2017-11-03 09:20:44.385 [INFO ] [marthome.model.script.GenerateGraphs] - Generated graphs.
2017-11-03 09:20:44.386 [INFO ] [rthome.model.script.GenerateGraphs] - Traceback (most recent call last):
File "C:\OpenHAB\conf\html\Graphs\GenerateGraphs.py", line 35, in <module>
os.remove(existing)
WindowsError: [Error 5] Access is denied: 'C:\\OpenHAB\\conf\\html\\Graphs\\HeatingFloorHeating.png'
2017-11-03 09:25:43.875 [INFO ] [marthome.model.script.GenerateGraphs] - Generated graphs.
2017-11-03 09:25:43.875 [INFO ] [rthome.model.script.GenerateGraphs] - Traceback (most recent call last):
File "C:\OpenHAB\conf\html\Graphs\GenerateGraphs.py", line 35, in <module>
os.remove(existing)
WindowsError: [Error 5] Access is denied: 'C:\\OpenHAB\\conf\\html\\Graphs\\HeatingFloorHeating.png'
2017-11-03 09:30:45.085 [INFO ] [marthome.model.script.GenerateGraphs] - Generated graphs.
2017-11-03 09:35:52.874 [INFO ] [marthome.model.script.GenerateGraphs] - Generated graphs.
2017-11-03 09:35:52.874 [INFO ] [rthome.model.script.GenerateGraphs] - Traceback (most recent call last):
File "C:\OpenHAB\conf\html\Graphs\GenerateGraphs.py", line 35, in <module>
os.remove(existing)
WindowsError: [Error 5] Access is denied: 'C:\\OpenHAB\\conf\\html\\Graphs\\HeatingFloorHeating.png'
You can see that it goes fine in the beginning and then fails, also before the last fail it succeeds once.
Is this a bug or am I abusing the purpose of the conf/html folder?
Thanks!
Greetings,
Frederic
EDIT: it only happens, but not always, when the page where the graphs are displayed is open in basicui. If I’m on another page without the graphs, it never happens.