Author: remi
Date: 2009-03-24 11:15:54 +0100 (Tue, 24 Mar 2009)
New Revision: 4203
Modified:
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/interpreters/GadgetInterpreter.py
Log:
* improved interpreter stop in daemon mode
Modified:
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/interpreters/GadgetInterpreter.py
===================================================================
---
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/interpreters/GadgetInterpreter.py
2009-03-24 09:46:59 UTC (rev 4202)
+++
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/interpreters/GadgetInterpreter.py
2009-03-24 10:15:54 UTC (rev 4203)
@@ -185,7 +185,6 @@
stderr = subprocess.STDOUT,
cwd = self.__workingPath,
env = self.__shellEnv)
- self.__setRun(True)
t = threading.Thread(target = self.__stdOutLoop)
t.start()
time.sleep(0.1)
@@ -196,23 +195,32 @@
def abort(self):
"""Abort the current execution of the interpreter.
"""
+ def killMe():
+ if os.name == 'nt':
+ import win32api
+ try:
+ win32api.TerminateProcess(int(self.__process._handle), -1)
+ except:
+ pass
+ else:
+ os.system("kill -9 " + str(self.__process.pid))
if not self.__getRun():
return
if self.__daemon:
self.__process.stdin.write("STOP\n")
self.__process.stdin.flush()
+ timeout = 5.0
+ while self.__process.poll() == None:
+ timeout -= 0.1
+ time.sleep(0.1)
+ if timeout <= 0.0:
+ killMe()
+ break
self.__setRun(False)
if self.__onGadgetStoppedCallback != None:
self.__onGadgetStoppedCallback()
else:
- if os.name == 'nt':
- import win32api
- try:
- win32api.TerminateProcess(int(self.__process._handle), -1)
- except:
- pass
- else:
- os.system("kill -9 " + str(self.__process.pid))
+ killMe()
#
--------------------------------------------------------------------------
# Loop to handling the stdout messages.
@@ -220,6 +228,7 @@
def __stdOutLoop(self):
"""Loop to handling the stdout messages.
"""
+ self.__setRun(True)
if self.__onGadgetStartedCallback != None:
self.__onGadgetStartedCallback()
while self.__getRun():
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn