serving icon indicating copy to clipboard operation
serving copied to clipboard

gRPC + Tensorflow Serving + Python: Termination issues

Open eriophora opened this issue 10 years ago • 3 comments

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.

eriophora avatar May 11 '16 20:05 eriophora

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.

sukritiramesh avatar May 12 '16 17:05 sukritiramesh

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.

viksit avatar May 19 '16 22:05 viksit

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!

sukritiramesh avatar Jul 26 '16 21:07 sukritiramesh