fix: fixed locked callback call on plugins
This commit is contained in:
parent
93bb633010
commit
81061cea24
@ -58,6 +58,12 @@ def on(event_name, *args, **kwargs):
|
||||
one(plugin_name, event_name, *args, **kwargs)
|
||||
|
||||
|
||||
def locked_cb(name, cb, *args, **kwargs):
|
||||
global locks
|
||||
with locks[name]:
|
||||
cb(*args, *kwargs)
|
||||
|
||||
|
||||
def one(plugin_name, event_name, *args, **kwargs):
|
||||
global loaded, locks
|
||||
|
||||
@ -67,8 +73,8 @@ def one(plugin_name, event_name, *args, **kwargs):
|
||||
callback = getattr(plugin, cb_name, None)
|
||||
if callback is not None and callable(callback):
|
||||
try:
|
||||
with locks["%s::%s" % (plugin_name, cb_name)]:
|
||||
_thread.start_new_thread(callback, (*args, *kwargs))
|
||||
lock_name = "%s::%s" % (plugin_name, cb_name)
|
||||
_thread.start_new_thread(locked_cb, (lock_name, callback, *args, *kwargs))
|
||||
except Exception as e:
|
||||
logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e))
|
||||
logging.error(e, exc_info=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user