Skip to content

Commit

Permalink
Python GA channel and server
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielmanistaatgoogle committed Jun 1, 2016
1 parent 6eb2380 commit 10da197
Show file tree
Hide file tree
Showing 9 changed files with 2,931 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/python/grpcio/grpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,3 +787,60 @@ def stop(self, grace):
very early in the grace period).
"""
raise NotImplementedError()


################################# Functions ################################


def channel_ready_future(channel):
"""Creates a Future tracking when a Channel is ready.
Cancelling the returned Future does not tell the given Channel to abandon
attempts it may have been making to connect; cancelling merely deactivates the
returned Future's subscription to the given Channel's connectivity.
Args:
channel: A Channel.
Returns:
A Future that matures when the given Channel has connectivity
ChannelConnectivity.READY.
"""
from grpc import _utilities
return _utilities.channel_ready_future(channel)


def insecure_channel(target, options=None):
"""Creates an insecure Channel to a server.
Args:
target: The target to which to connect.
options: A sequence of string-value pairs according to which to configure
the created channel.
Returns:
A Channel to the target through which RPCs may be conducted.
"""
from grpc import _channel
return _channel.Channel(target, None, options)


def server(generic_rpc_handlers, thread_pool, options=None):
"""Creates a Server with which RPCs can be serviced.
The GenericRpcHandlers passed to this function needn't be the only
GenericRpcHandlers that will be used to serve RPCs; others may be added later
by calling add_generic_rpc_handlers any time before the returned server is
started.
Args:
generic_rpc_handlers: Some number of GenericRpcHandlers that will be used
to service RPCs after the returned Server is started.
thread_pool: A futures.ThreadPoolExecutor to be used by the returned Server
to service RPCs.
Returns:
A Server with which RPCs can be serviced.
"""
from grpc import _server
return _server.Server(generic_rpc_handlers, thread_pool)
Loading

0 comments on commit 10da197

Please sign in to comment.