Commit c7d39f6
committed
fix: use context managers for file I/O to prevent resource leaks
- Replace json.load(open(...)) with context manager in layer_wise/utils.py
- Add __del__ method to CaptureOutputToFile to ensure file closure
- Use context manager for output_path_file.write() in accuracy.py
These changes ensure proper resource cleanup and prevent file handle leaks.
Signed-off-by: lxcxjxhx <lxcxjxhx@users.noreply.github.com>1 parent 4e7b7a9 commit c7d39f6
3 files changed
Lines changed: 11 additions & 3 deletions
File tree
- neural_compressor
- evaluation/lm_eval
- tensorflow/utils
- torch/algorithms/layer_wise
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
| 263 | + | |
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
311 | 316 | | |
312 | 317 | | |
313 | 318 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
179 | | - | |
| 180 | + | |
| 181 | + | |
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| |||
0 commit comments