Author: tack
Date: Wed Dec 19 20:55:21 2007
New Revision: 2916
Log:
If multiple Processes finish at once, the exit code of the last process
ends up being passed to the completed signal for _all_ the processes
that exited. So we have the watcher pass the pid to the callback so it
can decide whether or not to ignore it.
Modified:
trunk/base/src/notifier/popen.py
Modified: trunk/base/src/notifier/popen.py
==============================================================================
--- trunk/base/src/notifier/popen.py (original)
+++ trunk/base/src/notifier/popen.py Wed Dec 19 20:55:21 2007
@@ -169,6 +169,15 @@
return self.in_progress
+ def get_pid(self):
+ """
+ Returns the pid of the child process if it has been spawned. Otherwise
+ returns None
+ """
+ if self.child:
+ return self.child.pid
+
+
def write( self, line ):
"""
Write a string to the app.
@@ -302,10 +311,15 @@
return False
- def __child_died( self, status ):
+ def __child_died( self, pid, status ):
"""
Callback from watcher when the child died.
"""
+ if pid != self.get_pid():
+ # We received notification from the watcher concerning another
+ # process, so ignore.
+ return
+
self.__dead = True
self.stopping = False
# close IO handler and kill timer
@@ -315,6 +329,7 @@
self.child = None
if self.__kill_timer:
notifier.timer_remove( self.__kill_timer )
+ print "FINISHED '%s' WITH STATUS %d" % (self._cmd, status)
self.in_progress.finished(status >> 8)
self.in_progress = None
self.signals['completed'].emit(status >> 8)
@@ -457,7 +472,7 @@
else:
pid, status = os.waitpid( p.pid, os.WNOHANG )
except OSError:
- remove_proc.append( p )
+ remove_proc.append( (p, pid, status) )
continue
if not pid:
continue
@@ -466,10 +481,10 @@
log.error('error retrieving process information from %d' % p)
elif os.WIFEXITED( status ) or os.WIFSIGNALED( status ) or \
os.WCOREDUMP( status ):
- remove_proc.append( p )
+ remove_proc.append( (p, pid, status) )
# remove dead processes
- for p in remove_proc:
+ for p, pid, status in remove_proc:
if p in self.__processes:
# call stopped callback
callback = self.__processes[p]
@@ -477,7 +492,7 @@
# it, since it's possible the callback could call append
# again.
del self.__processes[p]
- callback(status)
+ callback(pid, status)
# check if this function needs to be called again
if not self.__processes:
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog