Skip to content

Commit 3e2d24a

Browse files
sjrctrichteer
authored andcommitted
Implement Halibot.reload
1 parent 8ab19eb commit 3e2d24a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

halibot/halibot.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,16 @@ def get_package(self, name):
120120
return importlib.import_module('halibot.packages.' + name)
121121

122122
# TODO: Reload a class, and restart all modules of that class
123-
def reload(self, cls):
124-
pass
123+
def reload(self, name):
124+
parent = 'halibot.packages.' + name
125+
for k,o in self.objects.items():
126+
if o.__module__.startswith(parent + '.') or o.__module__ == parent:
127+
o._shutdown()
128+
mod = importlib.reload(importlib.import_module(o.__module__))
129+
cls = getattr(mod, o.__class__.__name__)
130+
self.add_instance(k, cls(self, o.config))
131+
132+
125133

126134
# Restart a module instance by name
127135
def restart(self, name):

0 commit comments

Comments
 (0)