Dispose SQLAlchemy's engine in storage_tests/test_cached_storage.py#6337
Merged
c-bata merged 12 commits intooptuna:masterfrom Nov 28, 2025
Merged
Conversation
This was referenced Nov 12, 2025
Member
|
@fusawa-yugo Could you review this PR? |
fusawa-yugo
reviewed
Nov 14, 2025
Member
|
@sawa3030 Could you review this PR? |
Collaborator
|
It’s basically LGTM. I’d appreciate it if you could update the part pointed out here. |
Co-authored-by: fusawa-yugo <167162479+fusawa-yugo@users.noreply.github.com>
…y-engine-test-cached-storage
Collaborator
Author
|
Thank you for the comment. I've update the code accordingly. PTAL |
sawa3030
approved these changes
Nov 27, 2025
Collaborator
sawa3030
left a comment
There was a problem hiding this comment.
Thank you for the update. LGTM!
Contributor
|
LGTM. |
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.
Motivation
This PR is the follow-up on:
Engine#6303,and runs in parallel with::
storage_tests/test_with_server.py#6330, andstorage_tests/rdb_tests/test_storage.py#6338.The original PR did not cover all test cases. This PR addresses the remaining ones in
storage_tests/test_cached_storage.py.Important
With these PRs and this PR, all the tests creating
RDBStorageintest_storageshas been addressed.The remaining tests creating
RDBStorageis onlystudy_tests/test_study_summary.py, which creates theRDBStorageinstance for only two times and considered to be less likely to encounter the SQLAlchemy's issue.Description of the changes
RDBStoragewithin a context manager so thatstorage.engine.dispose()is executed every time.Note
To ensure that
dispose()is always called even when an assert fails, it should be invoked inside__exit__rather than at the end of the test function.Important
Most of the diff comes from increased indentation after introducing the context manager.