Skip to content

Commit 3774118

Browse files
committed
Unload all plugins when stopping the bot
1 parent e841928 commit 3774118

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

cloudbot/bot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def run(self):
130130
self.loop.run_until_complete(self._init_routine())
131131
# Wait till the bot stops. The stopped_future will be set to True to restart, False otherwise
132132
restart = self.loop.run_until_complete(self.stopped_future)
133+
self.loop.run_until_complete(self.plugin_manager.unload_all())
133134
self.loop.close()
134135
return restart
135136

cloudbot/plugin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ def load_all(self, plugin_dir):
112112
# Load plugins asynchronously :O
113113
yield from asyncio.gather(*[self.load_plugin(path) for path in path_list], loop=self.bot.loop)
114114

115+
@asyncio.coroutine
116+
def unload_all(self):
117+
yield from asyncio.gather(
118+
*[self.unload_plugin(path) for path in self.plugins.keys()], loop=self.bot.loop
119+
)
120+
115121
@asyncio.coroutine
116122
def load_plugin(self, path):
117123
"""

0 commit comments

Comments
 (0)