Page 1 of 1

[SOLVED] Domoticz crashing after update plugin

Posted: Saturday 29 January 2022 17:41
by Filip
Hi,
I have a plugin based on multithreading. You can find the code on https://github.com/FilipDem/Domoticz-NEST-plugin
All recommendations are followed. See the OnStop function extract below.
However if I update the plugin (eg because of changing a setting), domoticz hangs completely.
Anybody an idea what is wrong?

Code: Select all

    def onStop(self):
        Domoticz.Debug('> onStop called')
        
        # Signal queue thread to exit
        self.tasksQueue.put(None)
        self.tasksQueue.join()

        # Wait until queue thread has exited
        Domoticz.Debug('Threads still active: {} (should be 1)'.format(threading.active_count()))
        endTime = time.time() + 70
        while (threading.active_count() > 1) and (time.time() < endTime):
            for thread in threading.enumerate():
                if thread.name != threading.current_thread().name:
                    Domoticz.Debug('Thread {} is still running, waiting otherwise Domoticz will abort on plugin exit.'.format(thread.name))
            time.sleep(1.0)

Re: [SOLVED] Domoticz crashing after update plugin

Posted: Saturday 26 February 2022 11:29
by Filip
Problem found...

The statement refers to the "tasksQueue" instead of the thread.
Solved by updating self.tasksQueue.join() to self.tasksThread.join().