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:
Oleksandr Kozachuk
2026-07-14 21:30:43 +02:00
parent ef62cb41a5
commit da50395dc7
3 changed files with 30 additions and 10 deletions
+13 -1
View File
@@ -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):