Skip to content

Commit

Permalink
[core] Make module reloading call shutdown.
Browse files Browse the repository at this point in the history
- Also make it delete the setup function if one exists.
- Remove unnecessary guards from unregister. If the function is on the list,
  then it is obviously of the correct type.
  • Loading branch information
ari-koivula committed Jul 31, 2013
1 parent 9f15c0d commit ae8109b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def f_reload(bot, trigger):

old_callables = {}
for obj_name, obj in vars(old_module).iteritems():
if bot.is_callable(obj):
if bot.is_callable(obj) or bot.is_shutdown(obj):
old_callables[obj_name] = obj

bot.unregister(old_callables)
Expand All @@ -48,6 +48,10 @@ def f_reload(bot, trigger):
# module does not override them.
for obj_name in old_callables.keys():
delattr(old_module, obj_name)

# Also delete the setup function
if hasattr(old_module, "setup"):
delattr(old_module, "setup")

# Thanks to moot for prodding me on this
path = old_module.__file__
Expand Down

0 comments on commit ae8109b

Please sign in to comment.