def process(self):
with self.lock, self.enlock:<EOL><INDENT>queue = copy(self.queue)<EOL>self.queue.clear()<EOL>callbacks = copy(self.callbacks)<EOL><DEDENT>with self.lock:<EOL><INDENT>rm_cb = False<EOL>for ki, vi in queue.items():<EOL><INDENT>if ki in self.callbacks:<EOL><INDENT>for item in vi:<EOL><INDENT>for cb in self.callbacks[ki]:<EOL><INDENT>if cb(item) is False:<EOL><INDENT>callbacks[ki].remove(cb)<EOL>if not callbacks[ki]:<EOL><INDENT>del callbacks[ki]<EOL><DEDENT>rm_cb = True<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>with self.lock:<EOL><INDENT>if rm_cb:<EOL><INDENT>self.callbacks.clear()<EOL>for k, v in callbacks.items():<EOL><INDENT>self.callbacks[k].extend(v)<EOL><DEDENT><DEDENT>return len(self.callbacks)<EOL><DEDENT>
Process queue for these listeners. Only the items with type that
        matches