Skip to content

Commit

Permalink
turn off plugin hot-reload by default
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-husky committed Dec 9, 2023
1 parent 2f148ba commit 2f2b869
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
4 changes: 4 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@
BLOCK_INVALID_APIKEY = False


# 启用插件热加载
PLUGIN_HOT_RELOAD = False


# 自定义按钮的最大数量限制
NUM_CUSTOM_BASIC_BTN = 4

Expand Down
24 changes: 17 additions & 7 deletions toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,15 @@ def HotReload(f):
最后,使用yield from语句返回重新加载过的函数,并在被装饰的函数上执行。
最终,装饰器函数返回内部函数。这个内部函数可以将函数的原始定义更新为最新版本,并执行函数的新版本。
"""
@wraps(f)
def decorated(*args, **kwargs):
fn_name = f.__name__
f_hot_reload = getattr(importlib.reload(inspect.getmodule(f)), fn_name)
yield from f_hot_reload(*args, **kwargs)
return decorated
if get_conf('PLUGIN_HOT_RELOAD'):
@wraps(f)
def decorated(*args, **kwargs):
fn_name = f.__name__
f_hot_reload = getattr(importlib.reload(inspect.getmodule(f)), fn_name)
yield from f_hot_reload(*args, **kwargs)
return decorated
else:
return f


"""
Expand Down Expand Up @@ -916,7 +919,14 @@ def read_single_conf_with_lru_cache(arg):

@lru_cache(maxsize=128)
def get_conf(*args):
# 建议您复制一个config_private.py放自己的秘密, 如API和代理网址, 避免不小心传github被别人看到
"""
本项目的所有配置都集中在config.py中。 修改配置有三种方法,您只需要选择其中一种即可:
- 直接修改config.py
- 创建并修改config_private.py
- 修改环境变量(修改docker-compose.yml等价于修改容器内部的环境变量)
注意:如果您使用docker-compose部署,请修改docker-compose(等价于修改容器内部的环境变量)
"""
res = []
for arg in args:
r = read_single_conf_with_lru_cache(arg)
Expand Down

0 comments on commit 2f2b869

Please sign in to comment.