Repository navigation
fix(export_l5x): close SQLite connection after .project is built - #49
Merged
hutcheb merged 1 commit intoNov 3, 2026
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ExportL5x's sqlite connection is never closed — leaks a temp dir per file, can fill the diskSymptom
Converting many
.ACDfiles in one process (e.g. batch-converting a folder)leaves behind a growing pile of
acd_load_*/acd-build-*tempdirectories under the OS temp folder — one per file converted, never
cleaned up. Left running, this can fill the disk. This is not a
theoretical concern: running a batch conversion of ~770 real project files
in one process filled a 951 GB disk to 100% before it finished.
Root cause
ExportL5x.__post_init__opens a sqlite connection (self._db = sqlite3.connect(...)) against a database file inside its temp directory,and nothing in the class ever calls
self._db.close(). The typical callerpattern (see
acd.api.load_acd) is:On Windows, an open sqlite connection holds an OS-level file lock on its
database file.
exportergoes out of scope when the function returns, butPython's reference counting/GC doesn't guarantee the connection object (and
its file lock) is released by the time
shutil.rmtreeruns immediatelyafterward — and
shutil.rmtree(..., ignore_errors=True)silently swallowsthe resulting
PermissionError. The result: the temp directory is left ondisk, forever, every single call, with no error or warning of any kind.
Fix
Close
self._dbonce the object tree is fully built and nothing will queryit again — at the end of the
projectproperty getter, right before itreturns the built
RSLogix5000Content. Nothing after that point inExportL5x(or in the returned project) needs the sqlite connection.Suggested validation
Convert the same file in a loop (say, 50 times) in one process and confirm
the temp directory count under the OS temp folder doesn't grow. Before this
fix, it grows by one directory per call; after, it stays flat (each
directory is removed once its
ExportL5xinstance's connection is closed).🤖 Generated with Claude Code