def reload_plugin(bot, module_path):
"""reload a plugin and keep track of multiple reloads
Note: the plugin may reset the sentinal on a successfull internal load
Args:
module_path: string, plugin path on disk relative to the main script
Returns:
boolean, False if the plugin may not be reloaded again, otherwise True
"""
repeat = SENTINALS.setdefault(module_path, 0)
if repeat >= 3:
logger.critical('too many reloads of %s, enter failstate', module_path)
return False
SENTINALS[module_path] += 1
await unload(bot, module_path)
await load(bot, module_path)
return True
评论列表
文章目录