[SOLVED] Domoticz crashing after update plugin

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
Filip
Posts: 117
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

[SOLVED] Domoticz crashing after update plugin

Post 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)
Filip
Posts: 117
Joined: Thursday 03 November 2016 10:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [SOLVED] Domoticz crashing after update plugin

Post by Filip »

Problem found...

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

Who is online

Users browsing this forum: Bing [Bot] and 1 guest