changes to logging and threading

This commit is contained in:
XxKingsxX-Pinu
2024-07-09 04:22:18 +10:00
parent a100933678
commit 89a589af72
9 changed files with 58 additions and 20 deletions

View File

@ -1,4 +1,5 @@
import _thread
import threading
import glob
import importlib
import importlib.util
@ -95,8 +96,10 @@ def one(plugin_name, event_name, *args, **kwargs):
if callback is not None and callable(callback):
try:
lock_name = "%s::%s" % (plugin_name, cb_name)
loggingFormat = "%s.%s" % (plugin_name, cb_name)
locked_cb_args = (lock_name, callback, *args, *kwargs)
_thread.start_new_thread(locked_cb, locked_cb_args)
#_thread.start_new_thread(locked_cb, locked_cb_args)
threading.Thread(target=locked_cb, args=locked_cb_args, name=loggingFormat).start()
except Exception as e:
logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e))
logging.error(e, exc_info=True)