def fire(self, *args, **kw):
result = []<EOL>with self._hlock:<EOL><INDENT>handlers = self.handlers<EOL><DEDENT>if self.threads == <NUM_LIT:0>:  <EOL><INDENT>for k in handlers:<EOL><INDENT>h, m, t = handlers[k]<EOL>try:<EOL><INDENT>r = self._memoize(h, m, t, *args, **kw)<EOL>result.append(tuple(r))<EOL><DEDENT>except:<EOL><INDENT>result.append((False, self._error(sys.exc_info()), h))<EOL><DEDENT><DEDENT><DEDENT>elif self.threads > <NUM_LIT:0>:  <EOL><INDENT>queue = Queue()<EOL>rlock = RLock()<EOL>def _execute(*args, **kw):<EOL><INDENT>"""<STR_LIT>"""<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>item = queue.get()<EOL>if item is None:<EOL><INDENT>queue.task_done()<EOL>break<EOL><DEDENT>h, m, t = handlers[item]  <EOL>try:<EOL><INDENT>r = self._memoize(h, m, t, *args, **kw)<EOL>if not self.asynch:<EOL><INDENT>with rlock:<EOL><INDENT>result.append(tuple(r))<EOL><DEDENT><DEDENT><DEDENT>except:<EOL><INDENT>if not self.asynch:<EOL><INDENT>with rlock:<EOL><INDENT>result.append((False, self._error(sys.exc_info()), h))<EOL><DEDENT><DEDENT><DEDENT>queue.task_done()<EOL><DEDENT>except Empty:  <EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>if handlers:<EOL><INDENT>threads = self._threads(handlers=handlers)<EOL>for _ in range(threads):<EOL><INDENT>t = Thread(target=_execute, args=args, kwargs=kw)<EOL>t.daemon = True<EOL>t.start()<EOL><DEDENT>for k in handlers:<EOL><INDENT>queue.put(k)<EOL>if self.asynch:  <EOL><INDENT>h, _, _ = handlers[k]<EOL>result.append((None, None, h))<EOL><DEDENT><DEDENT>for _ in range(threads):<EOL><INDENT>queue.put(None)  <EOL><DEDENT>if not self.asynch:<EOL><INDENT>queue.join()<EOL><DEDENT><DEDENT><DEDENT>return tuple(result) or None<EOL>
Stores all registered handlers in a queue for processing