The dictionnary "Parameters" can it be currupted ?

Python and python framework

Moderator: leecollings

Post Reply
Thorgal789
Posts: 920
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

The dictionnary "Parameters" can it be currupted ?

Post 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 ?
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

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

Post 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
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
Thorgal789
Posts: 920
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

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

Post 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.
Post Reply