[
https://issues.apache.org/jira/browse/ARROW-16086?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17516327#comment-17516327
]
David Li commented on ARROW-16086:
----------------------------------
Ah so the reason why I suggest a thread is then the main thread is freed up and
you can handle KeyboardInterrupt. For instance
{code:python}
import threading
import time
import pyarrow.flight as flight
client = flight.connect("grpc://localhost:1337")
stream = client.do_get(flight.Ticket(b""))
def _read():
print("Reading")
try:
stream.read_all()
except flight.FlightCancelledError:
print("Cancelled")
print("Finished")
t = threading.Thread(target=_read)
t.start()
try:
time.sleep(60)
except KeyboardInterrupt:
stream.cancel()
print("Done")
{code}
You can Ctrl-C this and it will cancel the call.
On the server side, gRPC will refuse to interrupt or cancel a call. You must
check {{context.is_cancelled()}} and break out of the RPC handler yourself, or
the server will hang. (That is, even if the client cancels a call, the server
needs to manually react to this.)
> [Python] Calls to do_get ignore Python signal handlers
> ------------------------------------------------------
>
> Key: ARROW-16086
> URL: https://issues.apache.org/jira/browse/ARROW-16086
> Project: Apache Arrow
> Issue Type: Bug
> Components: FlightRPC, Python
> Reporter: Alex Bergeron
> Priority: Major
>
> Similar to ARROW-15106 but observed from the client, not the server.
> The Python Flight client blocks the thread and ignores signal handlers. This
> makes it impossible for the client to handle the signal handler and cancel
> the query before it has returned a FlightStreamReader.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)