mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
fix: fixed locked callback call on plugins
This commit is contained in:
@ -58,6 +58,12 @@ def on(event_name, *args, **kwargs):
|
|||||||
one(plugin_name, 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):
|
def one(plugin_name, event_name, *args, **kwargs):
|
||||||
global loaded, locks
|
global loaded, locks
|
||||||
|
|
||||||
@ -67,8 +73,8 @@ def one(plugin_name, event_name, *args, **kwargs):
|
|||||||
callback = getattr(plugin, cb_name, None)
|
callback = getattr(plugin, cb_name, None)
|
||||||
if callback is not None and callable(callback):
|
if callback is not None and callable(callback):
|
||||||
try:
|
try:
|
||||||
with locks["%s::%s" % (plugin_name, cb_name)]:
|
lock_name = "%s::%s" % (plugin_name, cb_name)
|
||||||
_thread.start_new_thread(callback, (*args, *kwargs))
|
_thread.start_new_thread(locked_cb, (lock_name, callback, *args, *kwargs))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e))
|
logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e))
|
||||||
logging.error(e, exc_info=True)
|
logging.error(e, exc_info=True)
|
||||||
|
Reference in New Issue
Block a user