diff --git a/pwnagotchi/plugins/__init__.py b/pwnagotchi/plugins/__init__.py index 56aa2d5..bef2672 100644 --- a/pwnagotchi/plugins/__init__.py +++ b/pwnagotchi/plugins/__init__.py @@ -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)