We now spawn a thread for invalidCommands when any of the plugins that will run invalidCommands are threaded.

This commit is contained in:
Jeremy Fincher 2005-04-13 03:20:58 +00:00
parent e1d3c5e537
commit c621905d91

View File

@ -652,13 +652,25 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
def _callInvalidCommands(self): def _callInvalidCommands(self):
log.debug('Calling invalidCommands.') log.debug('Calling invalidCommands.')
threaded = False
cbs = []
for cb in self.irc.callbacks: for cb in self.irc.callbacks:
if hasattr(cb, 'invalidCommand'): 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) self._callInvalidCommand(cb)
if self.msg.repliedTo: if self.msg.repliedTo:
log.debug('Done calling invalidCommands: %s.',cb.name()) log.debug('Done calling invalidCommands: %s.',cb.name())
return 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): def _callInvalidCommand(self, cb):
try: try: