Author: remi
Date: 2009-06-22 14:34:18 +0200 (Mon, 22 Jun 2009)
New Revision: 4852

Modified:
   
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
Log:
* improved plugin start/stop methods

Modified: 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
     2009-06-22 12:33:42 UTC (rev 4851)
+++ 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
     2009-06-22 12:34:18 UTC (rev 4852)
@@ -27,6 +27,7 @@
         self.__runMutex = threading.Lock()
         self.__run = False
         self.__process = None
+        self.__pid = None
         self.__daemon = False
         self.__onPluginStartedCallback = None
         self.__onPluginStoppedCallback = None
@@ -185,6 +186,11 @@
             stderr = subprocess.STDOUT,
             cwd = self.__workingPath,
             env = self.__shellEnv)
+        if os.name == 'nt':
+            self.__pid = self.__process._handle
+        else:
+            self.__pid = self.__process.pid
+        self.__setRun(True)
         t = threading.Thread(target = self.__stdOutLoop)
         t.start()
         time.sleep(0.1)
@@ -199,11 +205,11 @@
             if os.name == 'nt':
                 import win32api
                 try:
-                    win32api.TerminateProcess(int(self.__process._handle), -1)
+                    win32api.TerminateProcess(int(self.__pid), -1)
                 except:
                     pass
             else:
-                os.system("kill -9 " + str(self.__process.pid))
+                os.system("kill -3 -15 -9 " + str(self.__pid))
         if not self.__getRun():
             return
         if self.__daemon:
@@ -211,7 +217,7 @@
                 self.__process.stdin.write("STOP\n")
                 self.__process.stdin.flush()
             except:
-                return
+                pass
             timeout = 5.0
             while self.__process.poll() == None:
                 timeout -= 0.1
@@ -253,7 +259,6 @@
     def __stdOutLoop(self):
         """Loop to handling the stdout messages.
         """
-        self.__setRun(True)
         if self.__onPluginStartedCallback != None:
             self.__onPluginStartedCallback()
         while self.__getRun():


------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to