Update halting logic to fetch up-to-date page contents

This commit is contained in:
Kiril Kovachev 2023-09-05 19:57:31 +01:00
parent 1849b5e9ea
commit 51126f226b

View File

@ -73,7 +73,7 @@ def links_to_plaintext(text: str) -> str:
return str(parsed) return str(parsed)
ABORT_CHECK_INTERVAL = 5 ABORT_CHECK_INTERVAL = 15
HALT_PAGE = wikt_page("User:KovachevBot/halt") # Do not edit, please! HALT_PAGE = wikt_page("User:KovachevBot/halt") # Do not edit, please!
def iterate_with_abort_check(iterator: Iterator, interval: int = ABORT_CHECK_INTERVAL, halt_page = HALT_PAGE): def iterate_with_abort_check(iterator: Iterator, interval: int = ABORT_CHECK_INTERVAL, halt_page = HALT_PAGE):
@ -84,7 +84,7 @@ def iterate_with_abort_check(iterator: Iterator, interval: int = ABORT_CHECK_INT
for edit_count, value in enumerate(iterator): for edit_count, value in enumerate(iterator):
# Check halt page # Check halt page
if edit_count % interval == 0: if edit_count % interval == 0:
if "halt" in halt_page.text.casefold(): if "halt" in halt_page.get(force=True).casefold():
print(f"ERROR: BOT WAS MANUALLY HALTED BY {halt_page.userName()}", file=sys.stderr) print(f"ERROR: BOT WAS MANUALLY HALTED BY {halt_page.userName()}", file=sys.stderr)
return return
yield value yield value