Ejemplo n.º 1
0
class mainloop_c(object):
    
    def __init__(self):
        #Init Logging
        init_log()
        #Import Server/Client Modules
        from GlassController import controller
        from WebServer.WebServer import GlassWebServer_c
        
        self.controller = controller
        self.webserver = GlassWebServer_c(config.general.webserver_port)
        import IOCP
        self.IOCPclient = IOCP.IOCPClient.IOCPComm
        self.IOCPclient.set_config(config.general.IOCP_client)
        #Initalize variables
        self.go = True       
        self.loop_time= 1/60.0
        
#    def init_log(self):
#        print "Initialize Logging"
#        logging.basicConfig(level=logging.DEBUG, format='%(asctime)s.%(msecs)d %(levelname)s:%(message)s', datefmt='%H:%M:%S')
        
    def run(self):
        logging.info('MainLoop Started')
        
        try:
            while self.go:
                time.sleep(self.loop_time)
                self.controller.FS_Comm.process()
                self.controller.comp()
                self.controller.variables.change_check()
                
                
        except KeyboardInterrupt:
            logging.warning('Main Loop - Keyboard Interrupt')
            self.quit()
        #Shut down server
        
        
    def quit(self):
        self.go = False
        logging.info('Glass Server Quiting')
        #try:
        self.IOCPclient.quit()
        self.controller.quit()
        self.webserver.quit()
        time.sleep(3)
        logging.info("Threads Active - %r", threading._active)
        logging.shutdown()
        #sys.exit()
        #os._exit(os.EX_OK)
        os._exit(0)
        sys.exit()
Ejemplo n.º 2
0
 def __init__(self):
     #Init Logging
     init_log()
     #Import Server/Client Modules
     from GlassController import controller
     from WebServer.WebServer import GlassWebServer_c
     
     self.controller = controller
     self.webserver = GlassWebServer_c(config.general.webserver_port)
     import IOCP
     self.IOCPclient = IOCP.IOCPClient.IOCPComm
     self.IOCPclient.set_config(config.general.IOCP_client)
     #Initalize variables
     self.go = True       
     self.loop_time= 1/60.0