Skip to content

Cannot stop python client with Ctrl-C #3820

@yokoi-h

Description

@yokoi-h

I'm using grpc stream between a server process implemented by Golang and a client process in Python.
The client can receive values from the server with the stream. However when it comes to disconnecting from the client, it doesn't work well.

I made sample programs using the stream like below.
https://gist.github.com/yokoi-h/06ab4d802fa918884d38

Components in the sample program are as follows.

  • client1(add_count.py): sends count to server
  • server(sample_server.go): receives count and adds it to a variable inside
  • client2(monitor_count.py): receives total count from the server
    • client2(monitor_count.py) <----- server(sample_server.go) <---- client1(add_count.py)
    • these components are running in a different terminal.

If client1 sends count to server, then client2 can receive total count via the server.
But when hit Ctrl-C to quit client2 in the terminal, it's blocked and not possible to quit except using kill.

I would like to know how to finish a client that is reading stream with Ctrl-C.
If you can provide the example to stop with Ctrl-C, it would be great.

Thank you

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions