liuyu81 edited a comment 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 gRPC server 
is part of a CLI app and its life-cycle is controlled by end users. The gRPC 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to