We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ec12b17 commit 9cdfc65Copy full SHA for 9cdfc65
tensorizer/stream_io.py
@@ -149,6 +149,12 @@ def __init__(self,
149
self._end = end
150
self.closed = False
151
152
+ def __enter__(self):
153
+ return self
154
+
155
+ def __exit__(self, exc_type, exc_val, exc_tb):
156
+ self.close()
157
158
def __del__(self):
159
self.close()
160
@@ -219,6 +225,10 @@ def close(self):
219
225
self._curl.stdout.close()
220
226
self._curl.terminate()
221
227
self._curl.wait()
228
+ else:
229
+ # stdout is normally closed by the Popen.communicate() method,
230
+ # which we skip in favour of Popen.stdout.read()
231
+ self._curl.stdout.close()
222
232
self._curl = None
223
233
224
234
def readline(self):
0 commit comments