Author: dmeyer
Date: Tue Dec  4 14:37:01 2007
New Revision: 2910

Log:
refactor popen kill all code to not use step in popen.py

Modified:
   trunk/base/src/notifier/__init__.py
   trunk/base/src/notifier/popen.py

Modified: trunk/base/src/notifier/__init__.py
==============================================================================
--- trunk/base/src/notifier/__init__.py (original)
+++ trunk/base/src/notifier/__init__.py Tue Dec  4 14:37:01 2007
@@ -42,7 +42,8 @@
 # kaa.notifier imports
 import nf_wrapper as notifier
 
-from popen import *
+from popen import Process
+from popen import proclist as _proclist
 from callback import *
 from thread import *
 from timer import *
@@ -95,14 +96,17 @@
         return
     shutting_down = True
 
-    stop_all_processes()
+    _proclist.stop_all()
     signals["shutdown"].emit()
     signals["shutdown"].disconnect_all()
     signals["step"].disconnect_all()
 
     # Kill processes _after_ shutdown emits to give callbacks a chance to
     # close them properly.
-    kill_all_processes()
+    _proclist.kill_all()
+    while _proclist.check():
+        # wait until all processes are stopped
+        step()
     kill_jobserver()
     # Collect any zombies
     try:

Modified: trunk/base/src/notifier/popen.py
==============================================================================
--- trunk/base/src/notifier/popen.py    (original)
+++ trunk/base/src/notifier/popen.py    Tue Dec  4 14:37:01 2007
@@ -15,7 +15,7 @@
 # By inherting from the class you can also override the functions stdout_cb
 # and stderr_cb to process stdout and stderr line by line.
 #
-# The killall function of this class can be called at the end of the programm
+# The kill_all function of this class can be called at the end of the programm
 # to stop all running processes.
 #
 # -----------------------------------------------------------------------------
@@ -44,7 +44,7 @@
 #
 # -----------------------------------------------------------------------------
 
-__all__ = [ 'Process', 'stop_all_processes', 'kill_all_processes']
+__all__ = [ 'Process', 'proclist' ]
 
 # python imports
 import os
@@ -162,9 +162,9 @@
 
         # add child to watcher
         if not is_mainthread():
-            MainThreadCallback(_watcher.append, self, self.__child_died )
+            MainThreadCallback(proclist.append, self, self.__child_died )
         else:
-            _watcher.append( self, self.__child_died )
+            proclist.append( self, self.__child_died )
         self.in_progress = InProgress()
         return self.in_progress
 
@@ -490,7 +490,7 @@
         return True
 
 
-    def stopall( self ):
+    def stop_all( self ):
         if self.status != 'running':
             return
         # stop all childs without waiting
@@ -499,28 +499,14 @@
         self.status = 'stopping'
 
 
-    def killall( self ):
+    def kill_all( self ):
         # prevent recursion
         if not self.status in ('running', 'stopping'):
             return
         # make sure every child is stopped
-        self.stopall()
+        self.stop_all()
         self.status = 'stopped'
 
-        # now wait until all childs are dead
-        while self.__processes:
-            self.check()
-            try:
-                notifier.step()
-            except ( KeyboardInterrupt, SystemExit ), e:
-                pass
-            except:
-                log.exception( 'Unhandled exception during killall' )
-
 
 # global watcher instance
-_watcher = Watcher()
-
-# global killall function
-stop_all_processes = _watcher.stopall
-kill_all_processes = _watcher.killall
+proclist = Watcher()

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to