1 parent cdb8013 commit fc90aa0Copy full SHA for fc90aa0
1 file changed
hbutils/testing/capture/output.py
@@ -127,10 +127,18 @@ def _capture_via_tempfile() -> ContextManager[OutputCaptureResult]:
127
with redirect_stdout(f_stdout), redirect_stderr(f_stderr):
128
yield r
129
finally:
130
- r.put_result(
131
- pathlib.Path(stdout_file).read_text(encoding='utf-8'),
132
- pathlib.Path(stderr_file).read_text(encoding='utf-8'),
133
- )
+ if not f_stdout.closed:
+ f_stdout.close()
+ if not f_stderr.closed:
+ f_stderr.close()
134
+ try:
135
+ r.put_result(
136
+ pathlib.Path(stdout_file).read_text(encoding='utf-8'),
137
+ pathlib.Path(stderr_file).read_text(encoding='utf-8'),
138
+ )
139
+ except: # process for extreme cases to avoid lock stuck
140
+ r.put_result(None, None)
141
+ raise
142
143
144
@contextmanager
0 commit comments