Skip to content

Implemented Graceful Shutdown and Improved Log Detection#4

Open
cameron-b63 wants to merge 5 commits into
maxstellar:mainfrom
cameron-b63:main
Open

Implemented Graceful Shutdown and Improved Log Detection#4
cameron-b63 wants to merge 5 commits into
maxstellar:mainfrom
cameron-b63:main

Conversation

@cameron-b63
Copy link
Copy Markdown

@cameron-b63 cameron-b63 commented May 30, 2026

Implemented Graceful Shutdown and Improved Log Detection

As the name suggests, this PR comprises graceful shutdown (catching Windows shutdown/taskkill signals) and improved log file detection.

Graceful Shutdown

This was accomplished using the pywin32 library. A control handler function is attached to the library's api. Additionally, the Python standard library's atexit functionality registers stop() for even more coverage.

Improved Log Detection

Sometimes, Roblox caching means that the most recently created log does not necessarily contain anything useful. The most recently modified log file now competes with the most recently created log file, with most recently modified always winning. I kept the competition so the macro could log when this takes place.

Technical Debt

This PR adds one new library to requirements.txt.

@cameron-b63
Copy link
Copy Markdown
Author

I tested the same reproduction from before and some combination of changes appears to have resolved the issue. I still don't think it's fully robust against power loss, but the suggested hidden window solution looks like a lot more of a refactor than I'm interested in doing.

@cameron-b63 cameron-b63 marked this pull request as ready for review May 30, 2026 03:37
@maxstellar maxstellar requested a review from Copilot May 30, 2026 05:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds graceful shutdown handling for Windows session/console events via pywin32 plus atexit, and changes log-file selection to prefer the most-recently-modified .log over the most-recently-created one to work around Roblox cache behavior. It also adjusts .gitignore to stop ignoring README.md and start ignoring config.ini/crash.log.

Changes:

  • Register stop() with atexit and install a win32api.SetConsoleCtrlHandler callback covering logoff/shutdown/close/Ctrl-C/Ctrl-Break.
  • Rework get_latest_log_file() to compare ctime vs mtime "winners" and return the mtime winner, logging when they differ.
  • Add pywin32==311 to requirements.txt; un-ignore README.md and ignore generated config.ini/crash.log.

Reviewed changes

Copilot reviewed 1 out of 3 changed files in this pull request and generated 5 comments.

File Description
BiomeMacro.py Adds atexit/win32 shutdown handling and improved latest-log selection logic.
requirements.txt Adds pywin32==311 dependency required by the new shutdown handler.
.gitignore Stops ignoring README.md; starts ignoring config.ini and crash.log.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread BiomeMacro.py Outdated
Comment thread BiomeMacro.py Outdated
Comment thread BiomeMacro.py Outdated
Comment thread BiomeMacro.py Outdated
Comment thread BiomeMacro.py Outdated
cameron-b63 and others added 3 commits May 31, 2026 17:40
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@cameron-b63
Copy link
Copy Markdown
Author

Adressed copilot concerns now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants