Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
58205cf
Add cancellable wait_for_review polling
thekarannagpal Nov 24, 2026
cccaa6a
Address Proofline review feedback on cancellation
thekarannagpal Nov 24, 2026
2bf161a
Address second Proofline review findings
thekarannagpal Nov 24, 2026
aeee907
Address third Proofline review findings
thekarannagpal Nov 24, 2026
f2e4288
Address fourth Proofline review findings
thekarannagpal Nov 24, 2026
3167ded
Address fifth Proofline review findings
thekarannagpal Nov 24, 2026
83c1ac9
Address sixth Proofline review findings
thekarannagpal Nov 25, 2026
cf1208a
Address seventh Proofline review findings
thekarannagpal Nov 25, 2026
473696c
Address eighth Proofline review findings
thekarannagpal Nov 25, 2026
6c684ea
Address ninth Proofline review findings
thekarannagpal Nov 25, 2026
7533b73
Address tenth Proofline review findings
thekarannagpal Nov 25, 2026
8fc5117
Address eleventh Proofline review findings
thekarannagpal Nov 25, 2026
2efa007
Address twelfth Proofline review findings
thekarannagpal Nov 25, 2026
d2ecdac
Address thirteenth Proofline review findings
thekarannagpal Nov 25, 2026
9388498
Address fourteenth Proofline review findings
thekarannagpal Nov 27, 2026
63c2476
Address fifteenth Proofline review findings
thekarannagpal Nov 27, 2026
0e4f110
Address sixteenth Proofline review findings
thekarannagpal Nov 28, 2026
c9753b6
Address seventeenth Proofline review findings
thekarannagpal Nov 28, 2026
4447440
Address eighteenth Proofline review findings
thekarannagpal Nov 28, 2026
5b3abb4
Address nineteenth Proofline review findings
thekarannagpal Nov 28, 2026
d27e21d
Address twentieth Proofline review findings
thekarannagpal Nov 28, 2026
c8f64b2
Address twenty-first Proofline review findings
thekarannagpal Nov 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,34 @@ if outcome.status != "COMPLETED":
print(outcome.status, outcome.reason)
```

`head_commit_sha` is a full SHA of 40 or 64 hexadecimal characters; any other value raises `ValueError` before a request. A review pinned to another head ends the wait on the read that names it. Its outcome is `INCOMPLETE` whatever the review's own status, its last gap has the reason code `HEAD_COMMIT_MISMATCH`, and `reason` says that the review is pinned to another head commit. A settled review that names no head has `HEAD_COMMIT_UNAVAILABLE` instead and is not `COMPLETED` either. `outcome.review.head_commit_sha` is the commit the review is pinned to. A patch review's head is a derived revision ID, so no commit matches it. In a GitHub Actions `pull_request` job, `GITHUB_SHA` is the merge commit; pass the pull request's head.
`head_commit_sha` is a full SHA of 40 or 64 hexadecimal characters; any other value raises `ValueError` before a request. A review pinned to another head ends the wait on the read that names it. Its outcome is `INCOMPLETE` whatever the review's own status, its last gap has the reason code `HEAD_COMMIT_MISMATCH`, and `reason` says that the review is pinned to another head commit. A settled review that names no head has `HEAD_COMMIT_UNAVAILABLE` instead and is not `COMPLETED` either. If `cancel_event` is also set and cancellation is observed before the deadline, cancellation takes precedence over that mismatch: the status is `STOPPED`, the mismatch or unavailable-head gap is still attached, and `reason` is the cancellation reason. The response must still pass normal validation. A signal first delivered at or after the deadline is ignored and does not override the mismatch; because the deadline is checked first, a mismatch observed only after expiry returns `TIMED_OUT` with the `HEAD_COMMIT_MISMATCH` or `HEAD_COMMIT_UNAVAILABLE` gap. `outcome.review.head_commit_sha` is the commit the review is pinned to. A patch review's head is a derived revision ID, so no commit matches it. In a GitHub Actions `pull_request` job, `GITHUB_SHA` is the merge commit; pass the pull request's head.

## Cancelling a wait

Pass `cancel_event` to stop a wait when your own code no longer needs the result: a `threading.Event` for `wait_for_review` on `ProoflineClient`, or an `asyncio.Event` for `wait_for_review` on `AsyncProoflineClient`. Set it from another thread or task. For an `asyncio.Event`, use `loop.call_soon_threadsafe(lambda: cancel.set())` when the setter is another thread so the event loop resolves the setter at dispatch time. If your application already owns `SIGINT` handling, route cancellation through that handler instead of replacing it with `loop.add_signal_handler`. Do not call `threading.Event.set()` directly from a Python signal handler; have the handler hand off to another thread instead.

```python
import threading

cancel = threading.Event()
outcome = client.wait_for_review(organization_id, review_id, cancel_event=cancel)
# From another thread: cancel.set()
```

```python
import asyncio

cancel = asyncio.Event()
loop = asyncio.get_running_loop()
outcome = await async_client.wait_for_review(
organization_id,
review_id,
cancel_event=cancel,
)
# From another thread: loop.call_soon_threadsafe(lambda: cancel.set())
```

An event already set at entry, including with `timeout=0`, returns `STOPPED` before any request; the timeout clock starts after that initial check. Cancellation is then checked before each poll, during the backoff, and after each read. A signal delivered while arguments are validated is bounded by that entry deadline, so one delivered at or after expiry is ignored. The backoff waits on a latch fed by the supplied event's own condition and waiter registration, so a `set()` followed by `clear()` is still observed, overriding `wait()` implementations are never called by the SDK, and no short-slice polling is needed. An in-flight read is not interrupted: cancellation waits for that read to finish, including transport retries and their delays. Retry delays count toward the overall wait deadline, not a single per-attempt HTTP timeout. A signal first delivered at or after the overall deadline is ignored: it does not change the wait's result or suppress a read error that would otherwise propagate. Cancellation must be observable on the event you pass: call `set()` on that event. A cached bound standard `threading.Event.set()` still notifies that event's condition and works; a setter that bypasses the observed condition, or a direct mutation of a backing object, may not wake an in-progress backoff. For `asyncio.Event`, the setter must notify waiters registered on that same event; changing only a backing object's flag does not notify those waiters, though a flag that is still set can be observed at a check after a read. The SDK never binds the caller's async event to the wait's loop or assigns to the caller's `set()` attribute, so the same event may be reused later as long as it is not already bound to a different loop and has no waiters from one; those events are rejected under the waiter-registration lock before the first request. A cancelled wait returns `ReviewOutcome` with `status == "STOPPED"` and `reason == "The wait was cancelled by the caller."`. When a review had already been read, `outcome.review` still holds that last record, including when cancellation lands during a read that raises `ProoflineError` or just before the next poll; other exceptions still propagate. A retained review must still pass the normal response validation, including its review ID and head-commit checks: validation errors from either the current response or the retained review propagate even when cancellation is set. When `head_commit_sha` is supplied, a retained review pinned to another head (or to no head) still carries the matching `HEAD_COMMIT_MISMATCH` or `HEAD_COMMIT_UNAVAILABLE` gap; the status remains `STOPPED` and `reason` remains the cancellation reason. Passing the wrong event type raises `TypeError` before any request. Without `cancel_event`, waits keep their existing polling and timeout behavior.

## Review exports

Expand Down
Loading