You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/12/14 05:59:06 UTC

[GitHub] [arrow] liuyu81 commented on issue #11932: [Python] Unable to turn-off signal blocking for pyarrow flight RPC server

liuyu81 commented on issue #11932:
URL: https://github.com/apache/arrow/issues/11932#issuecomment-993185337


   @lidavidm thanks for the detailed explanation.
   
   my application scenario is likewise to that of @lupko, where the server is part of a CLI application and its life-cycle is controlled by end users. The clients are remote services consuming live streams of data as they become available; the clients don't voluntarily cancel requests, except when the streams are closed from the source. It therefore seems like a natural design choice to capture user-initiated `SIGINT` from the app, and issue an immediate shutdown of the gRPC server. 
   
   As suggested, I am now able to capture `SIGINT` by creating the gRPC server in a background thread and not invoking `serve()`, e.g.,
   
   ```python
   # see the original post for the definition of `TickServer`
   
   if __name__ == '__main__':
       server: Optional[TickServer] = None
   
       def create_server():
           global server
           with TickServer(location="grpc://127.0.0.1:8000") as server:
               server.stopped.wait()
   
       with ThreadPoolExecutor() as executor:
           try:
               fut = executor.submit(create_server)
               concurrent.futures.wait([fut])
           except KeyboardInterrupt:
               server.shutdown()
               print("interrupted")
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org