Added supybot.threadAllCommands.

This commit is contained in:
Jeremy Fincher 2004-01-20 22:09:10 +00:00
parent 4b1083931d
commit 03647ce53d
2 changed files with 16 additions and 5 deletions

View File

@ -474,7 +474,7 @@ class IrcObjectProxy(RichReplyMethods):
return
command = getattr(cb, name)
Privmsg.handled = True
if cb.threaded:
if cb.threaded or conf.supybot.threadAllCommands():
t = CommandThread(target=self._callCommand,
args=(name, command, cb))
t.start()
@ -595,14 +595,22 @@ class CommandThread(threading.Thread):
to run in threads.
"""
def __init__(self, target=None, args=None):
(name, command, cb) = args
(self.name, self.command, self.cb) = args
world.threadsSpawned += 1
threadName = 'Thread #%s for %s.%s' % (world.threadsSpawned,
cb.name(), name)
self.cb.name(), self.name)
log.debug('Spawning thread %s' % threadName)
threading.Thread.__init__(self, target=target,
name=threadName, args=args)
self.setDaemon(True)
self.originalThreaded = self.cb.threaded
self.cb.threaded = True
def run(self):
try:
threading.Thread.run(self)
finally:
self.cb.threaded = self.originalThreaded
class ConfigIrcProxy(RichReplyMethods):

View File

@ -149,11 +149,14 @@ number of seconds to throttle snarfed URLs, in order to prevent loops between
two bots snarfing the same URLs and having the snarfed URL in the output of
the snarf message."""))
supybot.register('threadAllCommands', registry.Boolean(False, """Determines
whether the bot will automatically thread all commands. At this point this
option exists almost exclusively for debugging purposes; it can do very little
except to take up more CPU."""))
###
# Reply/error tweaking.
###
# TODO: These should probably all be channel-specific.
supybot.registerGroup('reply')
supybot.reply.register('oneToOne', registry.Boolean(True, """Determines whether
the bot will send multi-message replies in a single messsage or in multiple