kunwp1 commented on code in PR #8260:
URL: https://github.com/apache/texera/pull/8260#discussion_r4592090584
##########
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:
This repeats the check and message from the top of `write()`. A small helper
called from both places would keep them in one spot:
```python
except queue.Full:
self._raise_if_upload_failed()
def _raise_if_upload_failed(self) -> None:
with self._lock:
exception = self._upload_exception
if exception is not None:
raise IOError(f"Background upload failed: {exception}") from
exception
```
Separately, `maxsize=_CHUNK_SIZE` counts chunks, so the real queue holds
65,536 of them (4 GiB) before this branch runs, which is also why the test
shrinks `_CHUNK_SIZE`. A smaller bound could be a follow-up.
##########
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:
`close()` runs on the test thread without a timeout, so if its fix
regresses, this test hangs the suite instead of failing. With the old
`put(None, block=True)` it sat in `close()` until I killed it with `--timeout`,
and CI's pytest has no default timeout. `@pytest.mark.timeout(5)` on this test
(already used in `core/util` tests) turns that into a failure. The writer
thread is still worth keeping, since the marker alone hung on the old code once
the stream was finalized.
--
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]