Skip to content

fix: use context manager for file read in wandb_util#116

Open
haosenwang1018 wants to merge 1 commit intothu-ml:mainfrom
haosenwang1018:fix/unclosed-file-handle
Open

fix: use context manager for file read in wandb_util#116
haosenwang1018 wants to merge 1 commit intothu-ml:mainfrom
haosenwang1018:fix/unclosed-file-handle

Conversation

@haosenwang1018
Copy link

Replace open(path).read() with with open(path) as f: f.read() in wandb_util.py to ensure the file descriptor is promptly closed instead of relying on garbage collection.

open().read() without a context manager leaks the file descriptor
until garbage collection. Use 'with open()' to ensure prompt cleanup.
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