def timeout_process_add_queue(self, module, cache_time):
<EOL>if module in self.timeout_update_due:<EOL><INDENT>return<EOL><DEDENT>key = self.timeout_queue_lookup.get(module)<EOL>if key:<EOL><INDENT>queue_item = self.timeout_queue[key]<EOL>queue_item.remove(module)<EOL>if not queue_item:<EOL><INDENT>del self.timeout_queue[key]<EOL>self.timeout_keys.remove(key)<EOL><DEDENT><DEDENT>if cache_time == <NUM_LIT:0>:<EOL><INDENT>self.timeout_update_due.append(module)<EOL>self.timeout_queue_lookup[module] = None<EOL><DEDENT>else:<EOL><INDENT>if cache_time not in self.timeout_keys:<EOL><INDENT>self.timeout_queue[cache_time] = set([module])<EOL>self.timeout_keys.append(cache_time)<EOL>self.timeout_keys.sort()<EOL>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>else:<EOL><INDENT>self.timeout_queue[cache_time].add(module)<EOL><DEDENT>self.timeout_queue_lookup[module] = cache_time<EOL><DEDENT>
Add a module to the timeout_queue if it is scheduled in the future or
if it is due for an update immediately just trigger that.

the timeout_queue is a dict with the scheduled time as the key and the
value is a list of module instance names due to be updated at that
point. An ordered list of keys is kept to allow easy checking of when
updates are due.  A list is also kept of which modules are in the
update_queue to save having to search for modules in it unless needed.