Ejemplo n.º 1
0
 def start_olad(self):
     def preexec():
         os.setpgrp()
     if not self.olad_pid:
         pid = search_for_process('olad')
         if not pid:
             self.LOG.info('starting olad...')
             self.olad_process = subprocess.Popen('olad', preexec_fn=preexec)
             pid = self.olad_process.pid
         self.LOG.info('olad pid=%s' % (pid))
         self.olad_pid = pid
Ejemplo n.º 2
0
        
    def run(self):
        self.auto_update_timer.start()
        while self.running:
            self.needs_update.wait()
            self.callback()
            self.needs_update.clear()
        self.auto_update_timer.cancel()
            
    def on_update_request(self, *args, **kwargs):
        self.needs_update.set()

class olaListener(threading.Thread):
    def __init__(self, **kwargs):
        threading.Thread.__init__(self)
        self.state = True
        self.socket = kwargs.get('socket')
        self.client = kwargs.get('client')
        
    def run(self):
        #print 'listener started'
        while self.state:
            i, o, e = select.select([self.socket], [], [])
            if self.socket in i:
                self.client.SocketReady()


if __name__ == '__main__':
    pid = search_for_process('olad')
    #print 'pid=', pid