From c621905d913ad50e20f254f8470d3675952bf789 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 13 Apr 2005 03:20:58 +0000 Subject: [PATCH] We now spawn a thread for invalidCommands when any of the plugins that will run invalidCommands are threaded. --- src/callbacks.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/callbacks.py b/src/callbacks.py index 56af455fa..90804d7d6 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -652,13 +652,25 @@ class NestedCommandsIrcProxy(ReplyIrcProxy): def _callInvalidCommands(self): log.debug('Calling invalidCommands.') + threaded = False + cbs = [] for cb in self.irc.callbacks: if hasattr(cb, 'invalidCommand'): - log.debug('Trying to call %s.invalidCommand.' % cb.name()) + cbs.append(cb) + threaded = threaded or cb.threaded + def callInvalidCommands(): + for cb in cbs: self._callInvalidCommand(cb) if self.msg.repliedTo: log.debug('Done calling invalidCommands: %s.',cb.name()) return + if threaded: + name = 'Thread #%s (for invalidCommands)' % world.threadsSpawned + t = world.SupyThread(callInvalidCommands, name=name) + t.setDaemon(True) + t.start() + else: + callInvalidCommands() def _callInvalidCommand(self, cb): try: