Check whether we actually have a httpd running when unloading rest_api.py

This commit is contained in:
jesopo 2018-12-08 08:56:47 +00:00
parent 476e4cc9c1
commit 281923a463

View file

@ -92,6 +92,7 @@ class Module(ModuleManager.BaseModule):
global _log global _log
_log = self.log _log = self.log
self.httpd = None
if self.bot.get_setting("rest-api", False): if self.bot.get_setting("rest-api", False):
self.httpd = http.server.HTTPServer(("", 5000), Handler) self.httpd = http.server.HTTPServer(("", 5000), Handler)
self.httpd.socket = ssl.wrap_socket(self.httpd.socket, self.httpd.socket = ssl.wrap_socket(self.httpd.socket,
@ -103,7 +104,8 @@ class Module(ModuleManager.BaseModule):
self.thread.start() self.thread.start()
def unload(self): def unload(self):
self.httpd.shutdown() if self.httpd:
self.httpd.shutdown()
@utils.hook("received.command.apikey", private_only=True) @utils.hook("received.command.apikey", private_only=True)
def api_key(self, event): def api_key(self, event):