channel.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:aiogrpc 作者: hubo1016 项目源码 文件源码
def channel_ready_future(channel):
    """Creates a Future that tracks when a Channel is ready.

  Cancelling the Future does not affect the channel's state machine.
  It merely decouples the Future from channel state machine.

  Args:
    channel: A Channel object.

  Returns:
    A Future object that matures when the channel connectivity is
    ChannelConnectivity.READY.
  """
    fut = channel._loop.create_future()
    def _set_result(state):
        if not fut.done() and state is _grpc.ChannelConnectivity.READY:
            fut.set_result(None)
    fut.add_done_callback(lambda f: channel.unsubscribe(_set_result))
    channel.subscribe(_set_result, try_to_connect=True)
    return fut
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号