gRPC + Tensorflow Serving + Python: Termination issues
Hi All-
I'm not sure if this is an issue with gRPC and so also belongs on the issue page over there or the way TensorFlow serving interacts with it, but I figure it will likely come up with others so I'm putting it here. Keep in mind I'm a complete gRPC neophyte and find its documentation a bit baffling.
It appears that if a (dynamic) stub is created as an attribute of a class, then the python script using an instance of that class will never halt. This may be related to issues gRPC issues 4986 and 5640. While it may not be an issue for the demo scripts presented in the tutorials, I don't think it's terribly outlandish to create a class you can import to manage all the stub / channel stuff, and so I think this may come up again for others.
Anyone have any thoughts? Creating a method like this:
def shutdown(self):
del self.channel
del self.stub
does not seem to fix it, unfortunately.
Hi @eriophora, thanks for reporting. I was able to reproduce the issue with the mnist_client.py in tensorflow_serving/example. It does indeed look like this might be related to gRPC, so left a comment on the related gRPC issue to see if there might be a good way to fix this.
Looks like this was added to GA : hsaliak modified the milestone: 2016/05/21 Milestone, GA 3 days ago
That said, one way is to create a callback that you can subscribe to, and as connections close, use that to do an explicit connection close.
Tricky thing is your callback needs to be created at the time of the object creation where you pass in the channel object into it, so you can reference it later.
This issue should now be fixed with the latest grpcio package -- please upgrade to 0.15.x and retry (I retried with mnist_client.py and it is fixed). Closing this issue for now, but please feel free to reopen if the issue remains. Thanks!