You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@arrow.apache.org by Rafael Telles <ra...@telles.dev> on 2022/05/26 16:31:35 UTC

FlightRPC operation cancelling

Hi,

I need to cancel calls to GetFlightInfo and GetStream on C++ from a second
thread. I see that FlightCallOptions has a stop_token which looks like I
should be able to use, but I don't know how... Is there any documentation
around this?

Thanks so much!

Re: FlightRPC operation cancelling

Posted by David Li <li...@apache.org>.
Hi Rafael,

It's not possible to cancel GetFlightInfo right now as that's made using the synchronous API and we don't expose the gRPC ClientContext. I've been prototyping async Flight APIs in C++ and as part of that cancellation would be better supported.

DoGet can be cancelled. Construct a StopSource [1] and provide the token() in the FlightCallOptions. Then call StopSource::RequestStop. Note that again, because we use synchronous gRPC APIs and we haven't done the work to plumb the StopSource to grpc::ClientContext, this can't cancel a blocking read from the server (it will only "cancel" in between two read calls).

I filed some issues to improve this [2][3]. The key thing we need to support however is [4]. 

[1]: https://github.com/apache/arrow/blob/2464b149b3d06c6c3e45136dad0f3956772ca487/cpp/src/arrow/util/cancel.h#L37
[2]: https://github.com/apache/arrow-cookbook/issues/220
[3]: https://issues.apache.org/jira/browse/ARROW-16671
[4]: https://issues.apache.org/jira/browse/ARROW-12938

-David

On Thu, May 26, 2022, at 12:31, Rafael Telles wrote:
> Hi,
> 
> I need to cancel calls to GetFlightInfo and GetStream on C++ from a second thread. I see that FlightCallOptions has a stop_token which looks like I should be able to use, but I don't know how... Is there any documentation around this?
> 
> Thanks so much!
>