How to interrupt AsyncBucket query?

Is there a nice way to interrupt AsyncBucket query?

I want to allow users to cancel the async fetching gracefully.

1 Like

Hi @yevsht, you can use the RxJava timeout operator to handle this scenario. The timeout will terminate the observable and free any resources that can be freed when that happens.

It may look something like this:

    Observable<AsyncN1qlQueryResult> result =
            .timeout(2, TimeUnit.SECONDS); 

I don’t think it helps my case… (the timeout)

@yevsht in the async world, what you want to do in addition to the timeout is to set the “server timeout” value on the query params. this in turn will send this timeout to the server and if the timeout is over the server will cancel the request. Thats very similar to interrupt.

There is no other way to interrupt other than let it time out, you can run manual commands from the query UI to stop long running n1ql queries though.

Can you please elaborate?