carloea2 commented on code in PR #8260:
URL: https://github.com/apache/texera/pull/8260#discussion_r4622233650


##########
amber/src/main/python/pytexera/storage/large_binary_output_stream.py:
##########
@@ -181,7 +181,18 @@ def upload_worker():
         # Write data in chunks
         data = bytes(b)
         for offset in range(0, len(data), _CHUNK_SIZE):
-            self._queue.put(data[offset : offset + _CHUNK_SIZE], block=True)
+            chunk = data[offset : offset + _CHUNK_SIZE]
+            while True:
+                try:
+                    self._queue.put(chunk, timeout=_QUEUE_TIMEOUT)
+                    break
+                except queue.Full:
+                    with self._lock:
+                        exception = self._upload_exception
+                    if exception is not None:
+                        raise IOError(
+                            f"Background upload failed: {exception}"
+                        ) from exception

Review Comment:
   Extracted the upload failure check and reused it at both sites.



##########
amber/src/test/python/pytexera/storage/test_large_binary_output_stream.py:
##########
@@ -232,6 +233,33 @@ def test_write_after_upload_error_raises_error(self, 
large_binary):
                 with pytest.raises(IOError):
                     stream.close()
 
+    def test_write_unblocks_when_upload_fails_with_full_queue(self, 
large_binary):

Review Comment:
   Added the five-second timeout. I confirmed it catches the old blocking close 
locally.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to