Page 1 of 1

The dictionnary "Parameters" can it be currupted ?

Posted: Friday 25 January 2019 21:10
by Thorgal789
Hi, I have a strange problem on a python plugin.
It seem all is working fine during some hours and roughly we have on log, errors like this one.

Code: Select all

onHeartbeat' failed 'KeyError'.
Error was because of Parameters[] Dictionnary. In fact I have error on all lines with Parameters["Mode2"] or Parameters["Mode1"] for exemple.
The plugin have started without problem, so the fields are existing for sure, but what can provoke an error with the same lines, some hours after.

This dictionnary is managed by python framework, it's impossible to change them using python code.

It's an issue, or I miss something ?

Re: The dictionnary "Parameters" can it be currupted ?

Posted: Saturday 26 January 2019 2:17
by Dnpwwo
@Thorgal789,

The Parameters dictionary is created on plugin start up and then not touched by the framework so your problem sounds strange. All the Mode* parameters are in the dictionary regardless of whether they are used or not so that should not be an issue.

As far as I know the plugins can modify the Parameters dictionary (I didn't do anything to prevent that) although I can't think of a good use case where that would be required.

I would suggest putting an exception handler like

Code: Select all

        try:
            ... 
        except Exception as inst:
            Domoticz.Error("Exception detail: '"+str(inst)+"'")
            DumpConfigToLog()
            raise
in that callback and dumping the dictionary to the Domoticz log so you can see what is going on

Re: The dictionnary "Parameters" can it be currupted ?

Posted: Saturday 26 January 2019 9:38
by Thorgal789
Thx, that was what I thought.
I really don't see how the plugin can modify this dictionary itself by error, and I have two problems, difficult to make a minimal code to reproduce the bug, and it's not me who have the bug.

I will add some exception handler, like you said, to find more infos.