From 7504c646b7a0b08695ba8fec1c3b4a3a99f998db Mon Sep 17 00:00:00 2001 From: Daniel Folkinshteyn Date: Fri, 6 Aug 2010 14:48:21 -0400 Subject: [PATCH] Status.processes: add output of currently active processes. Signed-off-by: James McCoy --- plugins/Status/plugin.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/Status/plugin.py b/plugins/Status/plugin.py index 1bc0dd2cf..3412bec4e 100644 --- a/plugins/Status/plugin.py +++ b/plugins/Status/plugin.py @@ -32,6 +32,7 @@ import os import sys import time import threading +import multiprocessing import subprocess import supybot.conf as conf @@ -97,12 +98,15 @@ class Status(callbacks.Plugin): def processes(self, irc, msg, args): """takes no arguments - Returns the number of processes that have been spawned. + Returns the number of processes that have been spawned, and list of + ones that are still active. """ - # TODO: maintain a dict of active subprocesses, so we can - # include a list thereof in output, linke in threads(). maybe? - s = format('I have spawned %n.', - (world.processesSpawned, 'process')) + ps = [multiprocessing.current_process().name] + ps = ps + [p.name for p in multiprocessing.active_children()] + s = format('I have spawned %n; %n %b still currently active: %L.', + (world.processesSpawned, 'process'), + (len(ps), 'process'), + len(ps), ps) irc.reply(s) processes = wrap(processes)