Skip to content

Commit 6fd1c62

Browse files
committed
fix: lower troubled mod threshold from 5 to 3 consecutive failures
With the 30-minute polling interval, 5 failures meant 2.5 hours before staff was notified. Extract MAX_POLL_FAILURES constant and set it to 3.
1 parent 1ef4dba commit 6fd1c62

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

plugins/nemp.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
nemp_logger = logging.getLogger("NEMPolling")
1515

16+
MAX_POLL_FAILURES = 3
17+
1618
help_dict = {
1719
"running": [
1820
"{0} running <true/false>",
@@ -50,12 +52,14 @@
5052
],
5153
"failedmods": [
5254
"{0} failedmods",
53-
"Shows a list of mods that have failed to be polled at least 5 times in a row and were disabled automatically.",
55+
f"Shows a list of mods that have failed to be polled at least {MAX_POLL_FAILURES} times in a row"
56+
" and were disabled automatically.",
5457
],
5558
"failcount": [
5659
"{0} failcount",
5760
"Shows how many times mods have failed to be polled so far. At least two failures in a row required.",
58-
"Mods that have failed being polled 5 times are excluded from this list. Check {0} failedmods for those mods.",
61+
f"Mods that have failed being polled {MAX_POLL_FAILURES} times are excluded from this list."
62+
" Check {0} failedmods for those mods.",
5963
],
6064
"showinfo": [
6165
"{0} showinfo <mod> [<path> [...]]",
@@ -217,15 +221,16 @@ async def polling_task(handle, _pipe):
217221
plugin.troubled_mods[mod_name] += 1
218222
current_troubled_mods.remove(mod_name)
219223

220-
if plugin.troubled_mods[mod_name] >= 5:
224+
if plugin.troubled_mods[mod_name] >= MAX_POLL_FAILURES:
221225
plugin.auto_disabled_mods[mod_name] = True
222226
the_poller.mods[mod_name]["active"] = False
223227
del plugin.troubled_mods[mod_name]
224228

225229
completely_failed_mods.append(mod_name)
226230

227231
nemp_logger.debug(
228-
f"Mod {mod_name} has failed to be polled at least 5 times, it has been disabled."
232+
"Mod %s has failed to be polled at least %d times, it has been disabled.",
233+
mod_name, MAX_POLL_FAILURES,
229234
)
230235

231236
the_poller.build_html()

0 commit comments

Comments
 (0)