[PyKDE] Run function in the background
    Fabian Steiner 
    lists at fabis-site.net
       
    Mon Feb 19 18:11:42 GMT 2007
    
    
  
Hello!
I am currently working on an application which controls several hosts in 
our network in order to ensure that there are online. This is done by a 
function called checkStatus() that needs to be called every 10 seconds. 
I tried the following (with checkStatus being called in __init__ as 
thread.start_new_thread(self.checkStatus, ()), but it did't work since 
it resulted in a segmentation fault:
[...]
checkStatus(self):
     while 1:
            if check_online('192.168.0.100'):
                self.ui.lblStatus.setText('ON')
                self.ui.btnOn.setEnabled(False)
                self.ui.btnOff.setEnabled(True)
            else:
                self.ui.lblStatus.setText('OFF')
                self.ui.btnOn.setEnabled(True)
                self.ui.btnOff.setEnabled(False)
            time.sleep(10)
Output:
fabi at einstein:~/dev/Server_Control$ python Server_Control.py
QObject: Cannot create children for a parent that is in a different thread.
QObject: Cannot create children for a parent that is in a different thread.
Segmentation fault
Is there any other way which would solve this issue?
Thanks,
Fabian
    
    
More information about the PyQt
mailing list