From 7f4a1be9f926651298a9adf681ddb94994dc899f Mon Sep 17 00:00:00 2001 From: Daniel Folkinshteyn Date: Thu, 5 Aug 2010 13:54:54 -0400 Subject: [PATCH] Status: add 'processes' command, the multiprocessing equivalent of the threads command. Signed-off-by: James McCoy --- plugins/Status/plugin.py | 12 ++++++++++++ plugins/Status/test.py | 2 ++ 2 files changed, 14 insertions(+) diff --git a/plugins/Status/plugin.py b/plugins/Status/plugin.py index 10ae9d824..1bc0dd2cf 100644 --- a/plugins/Status/plugin.py +++ b/plugins/Status/plugin.py @@ -94,6 +94,18 @@ class Status(callbacks.Plugin): irc.reply(s) threads = wrap(threads) + def processes(self, irc, msg, args): + """takes no arguments + + Returns the number of processes that have been spawned. + """ + # 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')) + irc.reply(s) + processes = wrap(processes) + def net(self, irc, msg, args): """takes no arguments diff --git a/plugins/Status/test.py b/plugins/Status/test.py index 4843c4145..de456b061 100644 --- a/plugins/Status/test.py +++ b/plugins/Status/test.py @@ -71,6 +71,8 @@ class StatusTestCase(PluginTestCase): def testThreads(self): self.assertNotError('threads') + def testProcesses(self): + self.assertNotError('processes') # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: