mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
@ -1,19 +1,17 @@
|
|||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
import _thread
|
||||||
import threading
|
import threading
|
||||||
import importlib
|
import importlib, importlib.util
|
||||||
import importlib.util
|
|
||||||
import logging
|
import logging
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
|
||||||
|
|
||||||
|
|
||||||
default_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "default")
|
default_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "default")
|
||||||
loaded = {}
|
loaded = {}
|
||||||
database = {}
|
database = {}
|
||||||
locks = {}
|
locks = {}
|
||||||
|
|
||||||
THREAD_POOL_SIZE = 10
|
|
||||||
executor = ThreadPoolExecutor(max_workers=THREAD_POOL_SIZE)
|
|
||||||
|
|
||||||
|
|
||||||
class Plugin:
|
class Plugin:
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -98,7 +96,7 @@ def one(plugin_name, event_name, *args, **kwargs):
|
|||||||
try:
|
try:
|
||||||
lock_name = "%s::%s" % (plugin_name, cb_name)
|
lock_name = "%s::%s" % (plugin_name, cb_name)
|
||||||
locked_cb_args = (lock_name, callback, *args, *kwargs)
|
locked_cb_args = (lock_name, callback, *args, *kwargs)
|
||||||
executor.submit(locked_cb, *locked_cb_args)
|
_thread.start_new_thread(locked_cb, locked_cb_args)
|
||||||
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