Skip to content

Commit 11231b6

Browse files
committed
fix(serialization): Don't accumulate os.pwrite results <= 0
1 parent 9d35e68 commit 11231b6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tensorizer/serialization.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,13 +3526,15 @@ def _pwrite_syscall(
35263526
verify if isinstance(verify, int) else self._buffer_size(data)
35273527
)
35283528
bytes_just_written: int = os.pwrite(self._fd, data, offset)
3529-
bytes_written += bytes_just_written
3529+
if bytes_just_written > 0:
3530+
bytes_written += bytes_just_written
35303531
while bytes_written < expected_bytes_written and bytes_just_written > 0:
35313532
# Writes larger than ~2 GiB may not complete in a single pwrite call
35323533
offset += bytes_just_written
35333534
with self._mv_suffix(data, bytes_written) as mv:
35343535
bytes_just_written = os.pwrite(self._fd, mv, offset)
3535-
bytes_written += bytes_just_written
3536+
if bytes_just_written > 0:
3537+
bytes_written += bytes_just_written
35363538
if isinstance(verify, int) or verify:
35373539
self._verify_bytes_written(bytes_written, expected_bytes_written)
35383540
return bytes_written

0 commit comments

Comments
 (0)