config reload: fix feedback loop — react to modified/created/moved only, not open/close (v3.12.1 spun cpu on read-opens)
This commit is contained in:
@@ -88,10 +88,22 @@ class ConfigFileHandler(FileSystemEventHandler):
|
||||
return True
|
||||
return False
|
||||
|
||||
def on_any_event(self, event):
|
||||
def _dispatch(self, event):
|
||||
if not event.is_directory and self._hits_config(event):
|
||||
self._on_change()
|
||||
|
||||
# Only write/rename events — NOT on_opened/on_closed, whose read-opens
|
||||
# (our own load_config re-reads the file) would otherwise feed back into
|
||||
# a reload loop (CFG-05).
|
||||
def on_modified(self, event):
|
||||
self._dispatch(event)
|
||||
|
||||
def on_created(self, event):
|
||||
self._dispatch(event)
|
||||
|
||||
def on_moved(self, event):
|
||||
self._dispatch(event)
|
||||
|
||||
|
||||
class FjerkroaBot(commands.Bot):
|
||||
def __init__(self, config_file: str):
|
||||
|
||||
Reference in New Issue
Block a user