Heartbeat and Multithreading

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Experienced User
Posts: 144
Joined: Sun Jun 02, 2013 4:01 am

Heartbeat and Multithreading

Post by abuttino » Tue May 06, 2014 3:46 am

I have a plugin I am trying to re-work for the ISY994i..

The SOAP subscription gives a heartbeat every 30 or so seconds but sometimes the SOAP subscription fails for whatever reason and the plugin is left without a new subscription. I've been working on this for at least the last 24 hours and I am at a point that I just need to reach out for help..

The Code:

Code: Select all

    def Polling(self, HB):
        #print 'you rang?'
        self.HB = HB
        if self.HB == 0:
            print 'Thread 1 started'
            t = threading.Timer(60.0, self.Polling, [1],{} )
            if self.mainstart == True:
                self.mainstart = False
        elif self.HB == 1:
            print 'Plugin Crashed, Attempting to restart'
            t = threading.Timer(3.0, self.plugin.restartplugin, [self.host, self.port, self.username, self.password],{} )
I am prepared to answer questions, but.. All I can say is after this goes past the 4th thread, things become quite a mess. with duplicate events and everything.

After reading about the Asyncore, I think this is one of my biggest problems here where I try to cancel the threads and they don't really cancel.

Posts: 3
Joined: Wed Nov 12, 2014 12:24 pm

Re: Heartbeat and Multithreading

Post by Begel » Wed Nov 12, 2014 12:27 pm


Post Reply