Skip to content

fix: HDFStore Resource Leak in DiskDatasetCache#2202

Open
Sagar-py wants to merge 1 commit intomicrosoft:mainfrom
Sagar-py:fix/hdfstore-resource-leak
Open

fix: HDFStore Resource Leak in DiskDatasetCache#2202
Sagar-py wants to merge 1 commit intomicrosoft:mainfrom
Sagar-py:fix/hdfstore-resource-leak

Conversation

@Sagar-py
Copy link
Copy Markdown

@Sagar-py Sagar-py commented May 5, 2026

Description

Replace manual pd.HDFStore open/close with a context manager in DiskDatasetCache.update() (qlib/data/cache.py)

Motivation and Context

The previous pattern relied on an explicit store.close() call that was never reached if any intermediate operation raised an exception. This leaked file descriptors and could leave the cache file in a partially-written corrupted state - making it all subsequent reads from that cache fail until the file was manually removed.

How Has This Been Tested?

  • Pass the test by running: pytest qlib/tests/test_all_pipeline.py under upper directory of qlib.
  • If you are adding a new feature, test on your own test scripts.

Types of changes

  • Fix bugs
  • Add new feature
  • Update documentation

@Sagar-py
Copy link
Copy Markdown
Author

Sagar-py commented May 5, 2026

@microsoft-github-policy-service agree

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.

1 participant