Author: remi
Date: 2009-08-01 13:53:46 +0200 (Sat, 01 Aug 2009)
New Revision: 5261

Modified:
   
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
Log:
* Fixed bug with subprocess.Popen (This module have a not safe-thread data 
access 
"http://mail.python.org/pipermail/python-bugs-list/2006-March/032626.html";)
* Fixed a not released PIPE's bug. (tracker ticket : #178 ?\226?\128?\148 
Tuxbox gadgets function freeze over time )

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-07-31 21:05:11 UTC (rev 5260)
+++ 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/plugin/interpreters/PluginInterpreter.py
     2009-08-01 11:53:46 UTC (rev 5261)
@@ -183,18 +183,18 @@
         if self.__daemon:
             shellEnv['tgp_daemon'] = 'true'
         shellCwd = self.__workingPath
-        try:
-            self.__process = subprocess.Popen(
-                shellCommand,
-                stdin = subprocess.PIPE,
-                stdout = subprocess.PIPE,
-                stderr = subprocess.STDOUT,
-                cwd = self.__workingPath,
-                env = self.__shellEnv)
-        except:
-            self.__setRun(False)
-            self.__workMutex.release()
-            return
+        while True:
+            try:
+                self.__process = subprocess.Popen(
+                    shellCommand,
+                    stdin = subprocess.PIPE,
+                    stdout = subprocess.PIPE,
+                    stderr = subprocess.STDOUT,
+                    cwd = self.__workingPath,
+                    env = self.__shellEnv)
+                break
+            except:
+                time.sleep(0.1)
         if os.name == 'nt':
             self.__pid = self.__process._handle
         else:
@@ -300,3 +300,15 @@
                         if self.__onNotificationThrowedCallback != None:
                             self.__onNotificationThrowedCallback(messageId,
                                 *args)
+        if self.__process != None:
+            # Close PIPE's
+            try:
+                if self.__process.stdin != None:
+                    self.__process.stdin.close()
+            except:
+                pass
+            try:
+                if self.__process.stdout != None:
+                    self.__process.stdout.close()
+            except:
+                pass


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to