From 80e4dfbe639825a39078156faafdc2fbf3d8799d Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sun, 20 Apr 2003 16:15:35 +0000 Subject: [PATCH] Added world.threadsSpawned, logging of the number of threads spawned, and added the information to cpustats. --- plugins/FunCommands.py | 6 ++++-- src/callbacks.py | 1 + src/world.py | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/FunCommands.py b/plugins/FunCommands.py index 326f193af..2ce69998f 100644 --- a/plugins/FunCommands.py +++ b/plugins/FunCommands.py @@ -330,11 +330,13 @@ class FunCommands(callbacks.Privmsg): 'children have taken %s seconds of user time and %s seconds'\ ' of system time for a total of %s seconds of CPU time. ' \ 'I\'ve taken a total of %s%% of this computer\'s time. ' \ - 'I currently have %s active %s.' %\ + 'Out of %s spawned %s, I have %s active.' %\ (user, system, user + system, childUser, childSystem, childUser + childSystem, (user+system+childUser+childSystem)/timeRunning, - threads, threads == 1 and 'thread' or 'threads') + world.threadsSpawned, + world.threadsSpawned == 1 and 'thread' or 'threads', + threads) irc.reply(msg, response) def uptime(self, irc, msg, args): diff --git a/src/callbacks.py b/src/callbacks.py index 7b9a39777..c0a1c0362 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -300,6 +300,7 @@ class IrcObjectProxy: class CommandThread(threading.Thread): def __init__(self, command, irc, msg, args): self.command = command + world.threadsSpawned += 1 self.commandName = command.im_func.func_name self.className = command.im_class.__name__ name = '%s.%s with args %r' % (self.className, self.commandName, args) diff --git a/src/world.py b/src/world.py index 2d45d840d..8c0a61aa7 100644 --- a/src/world.py +++ b/src/world.py @@ -52,6 +52,7 @@ version = '0.70.0' startedAt = 0.0 +threadsSpawned = 0 ### # End Global Values. ###