Struggling with duplicate triggers #580
Unanswered
FredericG-BE
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The same test-code as for the other discussion I opened on failing to register on mqtt messages at startup, demonstrates another issue I am struggling with. This time when I reload an app after startup
In the modules dir I have a mqttTestLib.py defining a class "HaspManager" that registers on mqtt messages in its constructor. In the apps folder I have mqttTest.py where an instance of HaspManager is created.
When I save mqttTest.py, it gets reloaded and a new instance of HaspManager is created but the old instance is still receiving the mqtt messages. So with each message that comes in, multiple instances on HaspManager handle the message. I am confused about that, when the "hm" variable is replaced, I would think the old instance is destroyed and also the reference to the trigger function looses references.
When I put the class definition code together with the app, all is fine (no duplicate triggers on messages) after reloading the app. So there seems to be a key difference here...
mqttTestLib.py:
mqttTest.py:
I was thinking that the class instance was not fully destroyed. For testing, I stored the trigger function in a global variable, so I was sure it would be replaced when a new instance would be created and the old trigger would be removed. However the same results...
Thanks for your help
Beta Was this translation helpful? Give feedback.
All reactions