Implemented Graceful Shutdown and Improved Log Detection#4
Conversation
|
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. |
There was a problem hiding this comment.
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()withatexitand install awin32api.SetConsoleCtrlHandlercallback 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==311torequirements.txt; un-ignoreREADME.mdand ignore generatedconfig.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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Adressed copilot concerns now |
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
pywin32library. A control handler function is attached to the library's api. Additionally, the Python standard library'satexitfunctionality registersstop()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.