mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-08 03:59:23 +01:00
Added supybot.threadAllCommands.
This commit is contained in:
parent
4b1083931d
commit
03647ce53d
@ -474,7 +474,7 @@ class IrcObjectProxy(RichReplyMethods):
|
|||||||
return
|
return
|
||||||
command = getattr(cb, name)
|
command = getattr(cb, name)
|
||||||
Privmsg.handled = True
|
Privmsg.handled = True
|
||||||
if cb.threaded:
|
if cb.threaded or conf.supybot.threadAllCommands():
|
||||||
t = CommandThread(target=self._callCommand,
|
t = CommandThread(target=self._callCommand,
|
||||||
args=(name, command, cb))
|
args=(name, command, cb))
|
||||||
t.start()
|
t.start()
|
||||||
@ -595,14 +595,22 @@ class CommandThread(threading.Thread):
|
|||||||
to run in threads.
|
to run in threads.
|
||||||
"""
|
"""
|
||||||
def __init__(self, target=None, args=None):
|
def __init__(self, target=None, args=None):
|
||||||
(name, command, cb) = args
|
(self.name, self.command, self.cb) = args
|
||||||
world.threadsSpawned += 1
|
world.threadsSpawned += 1
|
||||||
threadName = 'Thread #%s for %s.%s' % (world.threadsSpawned,
|
threadName = 'Thread #%s for %s.%s' % (world.threadsSpawned,
|
||||||
cb.name(), name)
|
self.cb.name(), self.name)
|
||||||
log.debug('Spawning thread %s' % threadName)
|
log.debug('Spawning thread %s' % threadName)
|
||||||
threading.Thread.__init__(self, target=target,
|
threading.Thread.__init__(self, target=target,
|
||||||
name=threadName, args=args)
|
name=threadName, args=args)
|
||||||
self.setDaemon(True)
|
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):
|
class ConfigIrcProxy(RichReplyMethods):
|
||||||
|
@ -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
|
two bots snarfing the same URLs and having the snarfed URL in the output of
|
||||||
the snarf message."""))
|
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.
|
# Reply/error tweaking.
|
||||||
###
|
###
|
||||||
|
|
||||||
# TODO: These should probably all be channel-specific.
|
|
||||||
supybot.registerGroup('reply')
|
supybot.registerGroup('reply')
|
||||||
supybot.reply.register('oneToOne', registry.Boolean(True, """Determines whether
|
supybot.reply.register('oneToOne', registry.Boolean(True, """Determines whether
|
||||||
the bot will send multi-message replies in a single messsage or in multiple
|
the bot will send multi-message replies in a single messsage or in multiple
|
||||||
|
Loading…
Reference in New Issue
Block a user