@profile<EOL><INDENT>def run(self):<DEDENT>
if self._py3_wrapper.running:<EOL><INDENT>cache_time = None<EOL>for meth, obj in self.methods.items():<EOL><INDENT>my_method = self.methods[meth]<EOL>if not self._py3_wrapper.running:<EOL><INDENT>break<EOL><DEDENT>if time() < obj["<STR_LIT>"]:<EOL><INDENT>if not cache_time or obj["<STR_LIT>"] < cache_time:<EOL><INDENT>cache_time = obj["<STR_LIT>"]<EOL><DEDENT>continue<EOL><DEDENT>try:<EOL><INDENT>method = getattr(self.module_class, meth)<EOL>if my_method["<STR_LIT>"] == self.PARAMS_NEW:<EOL><INDENT>response = method()<EOL><DEDENT>else:<EOL><INDENT>response = method(<EOL>self.i3status_thread.json_list,<EOL>self.config["<STR_LIT>"]["<STR_LIT>"],<EOL>)<EOL><DEDENT>if isinstance(response, dict):<EOL><INDENT>result = response<EOL><DEDENT>elif isinstance(response, tuple):<EOL><INDENT>position, result = response<EOL>if not isinstance(result, dict):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if isinstance(response.get("<STR_LIT>"), (list, Composite)):<EOL><INDENT>response["<STR_LIT>"] = response["<STR_LIT>"]<EOL>del response["<STR_LIT>"]<EOL><DEDENT>if "<STR_LIT>" in response:<EOL><INDENT>self.process_composite(response)<EOL><DEDENT>else:<EOL><INDENT>if "<STR_LIT>" not in result:<EOL><INDENT>err = '<STR_LIT>'<EOL>raise KeyError(err)<EOL><DEDENT>if hasattr(result.get("<STR_LIT>"), "<STR_LIT>"):<EOL><INDENT>del result["<STR_LIT>"]<EOL><DEDENT>if not self.allow_urgent and "<STR_LIT>" in result:<EOL><INDENT>del result["<STR_LIT>"]<EOL><DEDENT>result.update(self.i3bar_module_options)<EOL><DEDENT>result["<STR_LIT>"] = self.module_inst<EOL>result["<STR_LIT:name>"] = self.module_name<EOL>if my_method["<STR_LIT:name>"] is None:<EOL><INDENT>my_method["<STR_LIT:name>"] = result["<STR_LIT:name>"]<EOL>if "<STR_LIT>" in result:<EOL><INDENT>my_method["<STR_LIT>"] = result["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>my_method["<STR_LIT>"] = result["<STR_LIT:name>"]<EOL><DEDENT><DEDENT>if "<STR_LIT>" in result:<EOL><INDENT>cached_until = result["<STR_LIT>"]<EOL>del result["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>cached_until = self.module_class.py3.time_in()<EOL><DEDENT>my_method["<STR_LIT>"] = cached_until<EOL>if not cache_time or cached_until < cache_time:<EOL><INDENT>cache_time = cached_until<EOL><DEDENT>if "<STR_LIT>" in response:<EOL><INDENT>my_method["<STR_LIT>"] = result["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>my_method["<STR_LIT>"] = result<EOL><DEDENT>if self.config["<STR_LIT>"]:<EOL><INDENT>self._py3_wrapper.log(<EOL>"<STR_LIT>".format(meth, result)<EOL>)<EOL><DEDENT>self.allow_config_clicks = True<EOL>self.error_messages = None<EOL>self.error_hide = False<EOL>self.set_updated()<EOL><DEDENT>except ModuleErrorException as e:<EOL><INDENT>self.runtime_error(e.msg, meth)<EOL>if e.timeout:<EOL><INDENT>if e.timeout is PY3_CACHE_FOREVER:<EOL><INDENT>cache_time = PY3_CACHE_FOREVER<EOL><DEDENT>else:<EOL><INDENT>cache_time = time() + e.timeout<EOL><DEDENT><DEDENT>else:<EOL><INDENT>cache_time = time() + getattr(<EOL>self.module_class,<EOL>"<STR_LIT>",<EOL>self.config["<STR_LIT>"],<EOL>)<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>msg = "<STR_LIT>"<EOL>msg = msg.format(self.module_full_name, meth)<EOL>if not self.testing:<EOL><INDENT>self._py3_wrapper.report_exception(msg, notify_user=False)<EOL><DEDENT>self.runtime_error(str(e) or e.__class__.__name__, meth)<EOL>cache_time = time() + getattr(<EOL>self.module_class, "<STR_LIT>", self.config["<STR_LIT>"]<EOL>)<EOL><DEDENT><DEDENT>if cache_time is None:<EOL><INDENT>cache_time = time() + self.config["<STR_LIT>"]<EOL><DEDENT>self.cache_time = cache_time<EOL>if cache_time == PY3_CACHE_FOREVER:<EOL><INDENT>return<EOL><DEDENT>if not cache_time:<EOL><INDENT>cache_time = time() + self.config["<STR_LIT>"]<EOL><DEDENT>self._py3_wrapper.timeout_queue_add(self, cache_time)<EOL><DEDENT>
On a timely fashion, execute every method found for this module.
We will respect and set a cache timeout for each method if the user
didn't already do so.
We will execute the 'kill' method of the module when we terminate.