fix bug in beremiz_service with the MainLoop
authorgreg
Fri, 24 Oct 2008 14:36:52 +0200
changeset 263 0bc32427a459
parent 262 141a7145c099
child 264 06420c9fb656
fix bug in beremiz_service with the MainLoop
Beremiz_service.py
--- a/Beremiz_service.py	Fri Oct 24 14:01:36 2008 +0200
+++ b/Beremiz_service.py	Fri Oct 24 14:36:52 2008 +0200
@@ -177,7 +177,7 @@
         self.workdir = workdir
         self.args = args
         self.plcobj = None
-        self.servicepublisher = ServicePublisher.ServicePublisher()
+        self.servicepublisher = None
 
     def Loop(self):
         while self.continueloop:
@@ -203,7 +203,8 @@
         # Configure and publish service
         # Not publish service if localhost in address params
         if self.ip != "localhost" and self.ip != "127.0.0.1":    
-            print "Publish service on local network"            
+            print "Publish service on local network"
+            self.servicepublisher = ServicePublisher.ServicePublisher()            
             self.servicepublisher.RegisterService(self.name, self.ip, self.port)
         
         sys.stdout.flush()
@@ -211,7 +212,9 @@
         self.daemon.requestLoop()
     
     def Stop(self):
-        self.servicepublisher.UnRegisterService()
+        if self.servicepublisher is not None:
+            self.servicepublisher.UnRegisterService()
+            del self.servicepublisher
         self.daemon.shutdown(True)
 
 class ParamsEntryDialog(wx.TextEntryDialog):
@@ -335,6 +338,7 @@
     def OnTaskBarQuit(self,evt):
         pyroserver.Quit()
         self.RemoveIcon()
+        wx.GetApp().ExitMainLoop()
         
 pyroserver = Server(name, ip, port, WorkingDir, args)