-
Notifications
You must be signed in to change notification settings - Fork 11.1k
channel_ready_future().result() should return the channel, not None #14778
Copy link
Copy link
Closed
Labels
Description
What version of gRPC and what language are you using?
The Google internal version (which I believe tracks the latest release here).
What operating system (Linux, Windows, …) and version?
Linux
What runtime / compiler are you using (e.g. python version or version of gcc)
Python 2.7
What did you do?
def NewChannel(self):
channel_credentials = self._FetchCredentials()
channel = grpc.secure_channel(
'localhost:{}'.format(self._port), channel_credentials)
return grpc.channel_ready_future(channel).result()
What did you expect to see?
I was expecting the result of "NewChannel" to be the channel, itself.
What did you see instead?
Apparently, channel_ready_future's "result" is always None. Apparently the correct code (with the gRPC code as it is right now) is:
def NewChannel(self):
channel_credentials = self._FetchCredentials()
channel = grpc.secure_channel(
'localhost:{}'.format(self._port), channel_credentials)
grpc.channel_ready_future(channel).result()
return channel
However, this is because the behavior of ChannelReadyFuture violates the principle of least surprise; a future whose name is described with the name of some other noun should be returning an object of that noun type on completion; a "channel ... future" should be returning a channel.
Reactions are currently unavailable