Browse Source

Keep dynamic module in an attr so it doesn't get dealloc'd

tags/v0.1^2
Ben Kurtovic 13 years ago
parent
commit
69b7cb1a78
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      earwigbot/irc/watcher.py

+ 3
- 2
earwigbot/irc/watcher.py View File

@@ -81,19 +81,20 @@ class Watcher(IRCConnection):
This will get put in the function self._process_hook, which takes an RC This will get put in the function self._process_hook, which takes an RC
object and returns a list of frontend channels to report this event to. object and returns a list of frontend channels to report this event to.
""" """
# Default RC process hook does nothing:
# Set a default RC process hook that does nothing:
self._process_hook = lambda rc: () self._process_hook = lambda rc: ()
try: try:
rules = config.data["rules"] rules = config.data["rules"]
except KeyError: except KeyError:
return return
module = imp.new_module("_rc_event_rules")
module = imp.new_module("_rc_event_processing_rules")
try: try:
exec compile(rules, config.config_path, "exec") in module.__dict__ exec compile(rules, config.config_path, "exec") in module.__dict__
except Exception: except Exception:
e = "Could not compile config file's RC event rules" e = "Could not compile config file's RC event rules"
self.logger.exception(e) self.logger.exception(e)
return return
self._process_hook_module = module
try: try:
self._process_hook = module.process self._process_hook = module.process
except AttributeError: except AttributeError:


Loading…
Cancel
Save