You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5fc5a14
Browse filesBrowse the repository at this point in the historyBrowse files
fix: close remaining temp-file and cancellation gaps in NDJSON mode
Addresses review findings on the elements-file path.
Orphaned files on failure. Both `_ndjson_elements_file` helpers create their
destination with delete=False, so a body that raises or is cancelled partway
through left the partial copy behind; they now unlink it and re-raise.
`write_chunk_body_to_temp` had the same shape -- the caller only registers the
path for cleanup once the function returns, so a failed write orphaned the file,
and a full disk is exactly the failure that repeats.
Cancellation race. Recombination runs in a worker thread that cancellation cannot
interrupt, so `_clear_operation` could tear the operation down while it was still
running; publishing the path afterwards resurrected a cleared dict entry and
orphaned the file. Publishing is now gated on the operation still being live,
under a lock that `_clear_operation` also takes when dropping
`pending_operation_ids`. Ownership is explicit either way: the success path claims
the path out of `ndjson_output_path`, so anything still recorded at teardown was
never delivered and is safe to delete.
Docs regeneration. docs/models/operations/partitionresponse.md is generated and
tracked in gen.lock, and the generation workflow runs on a daily cron, so the
elements_file row would have been dropped within a day of merging. Added to
.genignore alongside the model, and the regeneration guard now asserts the row.
README. Noted that the memory saving applies to the split-PDF path -- unsplit
inputs still buffer the body -- so the caveat is visible where the feature is
advertised rather than only in the PR. The example's cleanup used a bare unlink in
a finally, which would mask a failure to open the file with FileNotFoundError; it
now uses Path.unlink(missing_ok=True).
The spilled-body regression guard asserted against `_content` it had assigned
itself, so it could not fail if the hook stopped releasing the body. It now drives
`_elements_from_task_responses`, and was confirmed to fail with the release
removed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -433,10 +433,13 @@ For very large documents, the parsed element list can dominate the client's memo
433
433
434
434
**You own the returned file and are responsible for deleting it.**
435
435
436
+
> [!NOTE]
437
+
> The memory saving applies to the split-PDF path, i.e. a PDF with `split_pdf_page=True` (the default). For unsplit inputs — a non-PDF file, or `split_pdf_page=False` — the response body is still read fully into memory before being written to disk, so peak memory can reach roughly twice the body size. You still get `elements_file` either way.
438
+
436
439
Example:
437
440
```python
438
441
import json
439
-
importos
442
+
from pathlib importPath
440
443
441
444
from unstructured_client.general import PartitionAcceptEnum
442
445
@@ -451,7 +454,8 @@ try:
451
454
element = json.loads(line)
452
455
...
453
456
finally:
454
-
os.unlink(res.elements_file)
457
+
# missing_ok so a failure to open the file isn't masked by the cleanup.
0 commit comments