plugin handler spawns daemon threads

instead of calling the hooks all blocking-like and such
master
BuildTools 3 years ago
parent 9dc14f69b7
commit f23b7d5376
  1. 3
      README.md
  2. 4
      plugin_manager.py

@ -15,7 +15,7 @@ framework for discord bots that uses contained files for individual feature plug
* make sure broken sockets are properly addressed with a resume or reconnect
* initial presence in config
* full REST api implementation
* plugins need to be asynchronously run (or something)
### plugins:
* save session config to file
@ -26,3 +26,4 @@ framework for discord bots that uses contained files for individual feature plug
* ~~default plugins so the bot does _something_ out of the box~~
* ~~plugin reloading, user (command) authentication, etc. will also probably be written in plugin form~~
* ~~take config as cli param~~
* ~~plugins need to be asynchronously run (or something)~~

@ -1,6 +1,6 @@
import os
import sys
import threading
class plugin_manager():
def __init__(self, logger, plugin_path = "./plugins"):
self.logger = logger
@ -26,7 +26,7 @@ class plugin_manager():
for plugin in self.plugins_loaded:
if event in plugin.hooks:
try:
getattr(plugin, "run")(event, ctx, bot)
threading.Thread(target=getattr(plugin, "run"), args=(event, ctx, bot), daemon=True).start()
except Exception as e:
bot.logger.write(e)
def __del__(self):

Loading…
Cancel
Save