Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document gRPC client-side request cancellation #416

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,41 @@ Advanced users may call the Python client via `async` and `await` syntax. The
[stream](src/python/examples/simple_grpc_aio_sequence_stream_infer_client.py)
examples demonstrate how to infer with AsyncIO.


### Request Cancellation

Starting from r23.10, triton python gRPC client can issue cancellation
to inflight requests. This can be done by calling `cancel()` on the
CallContext object returned by `async_infer()` API.

```python
ctx = client.async_infer(...)
ctx.cancel()
```

For streaming requests, `cancel_requests=True` can be sent to
`stop_stream()` API to terminate all the inflight requests
sent via this stream.

```python
client.start_stream()
for _ in range(10):
client.async_stream_infer(...)

# Cancels all pending requests on stream closure rather than blocking until requests complete
client.stop_stream(cancel_requests=True)
```

See more details about these APIs in
[grpc/\_client.py](src/python/library/tritonclient/grpc/_client.py).

See [request_cancellation](https://github.com/triton-inference-server/server/blob/main/docs/user_guide/request_cancellation.md)
in the server user-guide to learn about how this is handled on the
server side.
If writing your own gRPC clients in the language of choice consult
gRPC guide on [cancellation](https://grpc.io/docs/guides/cancellation/#cancelling-an-rpc-call-on-the-client-side).


## Simple Example Applications

This section describes several of the simple example applications and
Expand Down
Loading