Skip to content

channel_ready_future().result() should return the channel, not None #14778

@michaelsafyan

Description

@michaelsafyan

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions