def timeout_queue_process(self):
<EOL>while self.timeout_add_queue:<EOL><INDENT>self.timeout_process_add_queue(*self.timeout_add_queue.popleft())<EOL><DEDENT>now = time.time()<EOL>due_timeouts = []<EOL>for timeout in self.timeout_keys:<EOL><INDENT>if timeout > now:<EOL><INDENT>break<EOL><DEDENT>due_timeouts.append(timeout)<EOL><DEDENT>if due_timeouts:<EOL><INDENT>for timeout in due_timeouts:<EOL><INDENT>modules = self.timeout_queue[timeout]<EOL>del self.timeout_queue[timeout]<EOL>self.timeout_keys.remove(timeout)<EOL>for module in modules:<EOL><INDENT>del self.timeout_queue_lookup[module]<EOL>self.timeout_update_due.append(module)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>self.timeout_due = self.timeout_keys[<NUM_LIT:0>]<EOL><DEDENT>except IndexError:<EOL><INDENT>self.timeout_due = None<EOL><DEDENT><DEDENT>while self.timeout_finished:<EOL><INDENT>module_name = self.timeout_finished.popleft()<EOL>self.timeout_running.discard(module_name)<EOL>if module_name in self.timeout_missed:<EOL><INDENT>module = self.timeout_missed.pop(module_name)<EOL>self.timeout_update_due.append(module)<EOL><DEDENT><DEDENT>while self.timeout_update_due:<EOL><INDENT>module = self.timeout_update_due.popleft()<EOL>module_name = getattr(module, "<STR_LIT>", None)<EOL>if module_name and module_name in self.timeout_running:<EOL><INDENT>self.timeout_missed[module_name] = module<EOL><DEDENT>else:<EOL><INDENT>self.timeout_running.add(module_name)<EOL>Runner(module, self, module_name)<EOL><DEDENT><DEDENT>if self.timeout_due is not None:<EOL><INDENT>return self.timeout_due - time.time()<EOL><DEDENT>
Check the timeout_queue and set any due modules to update.