refactor(event): 事件处理调整为深复制,避免多线程环境下数据异常
This commit is contained in:
parent
da2c755b6d
commit
2b8c313019
@ -1,3 +1,4 @@
|
|||||||
|
import copy
|
||||||
import importlib
|
import importlib
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
@ -11,8 +12,7 @@ from app.chain.subscribe import SubscribeChain
|
|||||||
from app.chain.system import SystemChain
|
from app.chain.system import SystemChain
|
||||||
from app.chain.transfer import TransferChain
|
from app.chain.transfer import TransferChain
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.event import Event as ManagerEvent
|
from app.core.event import Event as ManagerEvent, eventmanager, EventManager
|
||||||
from app.core.event import eventmanager, EventManager
|
|
||||||
from app.core.plugin import PluginManager
|
from app.core.plugin import PluginManager
|
||||||
from app.helper.message import MessageHelper
|
from app.helper.message import MessageHelper
|
||||||
from app.helper.thread import ThreadHelper
|
from app.helper.thread import ThreadHelper
|
||||||
@ -194,7 +194,7 @@ class Command(metaclass=Singleton):
|
|||||||
# 插件事件
|
# 插件事件
|
||||||
self.threader.submit(
|
self.threader.submit(
|
||||||
self.pluginmanager.run_plugin_method,
|
self.pluginmanager.run_plugin_method,
|
||||||
class_name, method_name, event
|
class_name, method_name, copy.deepcopy(event)
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -217,7 +217,7 @@ class Command(metaclass=Singleton):
|
|||||||
if hasattr(class_obj, method_name):
|
if hasattr(class_obj, method_name):
|
||||||
self.threader.submit(
|
self.threader.submit(
|
||||||
getattr(class_obj, method_name),
|
getattr(class_obj, method_name),
|
||||||
event
|
copy.deepcopy(event)
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"事件处理出错:{str(e)} - {traceback.format_exc()}")
|
logger.error(f"事件处理出错:{str(e)} - {traceback.format_exc()}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user