From f55606cfb4bfb8a23f3a74fc430bc342dbae4b53 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. --- 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 fccd58336..dcc952d9e 100644 --- a/plugins/Status/plugin.py +++ b/plugins/Status/plugin.py @@ -93,6 +93,18 @@ class Status(callbacks.Plugin): (len(threads), 'thread'), len(threads), threads) 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: