Status.processes: add output of currently active processes.

Signed-off-by: James McCoy <jamessan@users.sourceforge.net>
This commit is contained in:
Daniel Folkinshteyn 2010-08-06 14:48:21 -04:00 committed by James McCoy
parent 141b120a9c
commit 7504c646b7

View File

@ -32,6 +32,7 @@ import os
import sys import sys
import time import time
import threading import threading
import multiprocessing
import subprocess import subprocess
import supybot.conf as conf import supybot.conf as conf
@ -97,12 +98,15 @@ class Status(callbacks.Plugin):
def processes(self, irc, msg, args): def processes(self, irc, msg, args):
"""takes no arguments """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 ps = [multiprocessing.current_process().name]
# include a list thereof in output, linke in threads(). maybe? ps = ps + [p.name for p in multiprocessing.active_children()]
s = format('I have spawned %n.', s = format('I have spawned %n; %n %b still currently active: %L.',
(world.processesSpawned, 'process')) (world.processesSpawned, 'process'),
(len(ps), 'process'),
len(ps), ps)
irc.reply(s) irc.reply(s)
processes = wrap(processes) processes = wrap(processes)