Public Member Functions | Private Attributes | List of all members
grpc.aio._server.Server Class Reference
Inheritance diagram for grpc.aio._server.Server:
Inheritance graph
[legend]

Public Member Functions

def __del__ (self)
 
def __init__ (self, Optional[Executor] thread_pool, Optional[Sequence[grpc.GenericRpcHandler]] generic_handlers, Optional[Sequence[Any]] interceptors, ChannelArgumentType options, Optional[int] maximum_concurrent_rpcs, Optional[grpc.Compression] compression)
 
None add_generic_rpc_handlers (self, Sequence[grpc.GenericRpcHandler] generic_rpc_handlers)
 
int add_insecure_port (self, str address)
 
int add_secure_port (self, str address, grpc.ServerCredentials server_credentials)
 
None start (self)
 
None stop (self, Optional[float] grace)
 
bool wait_for_termination (self, Optional[float] timeout=None)
 

Private Attributes

 _loop
 
 _server
 

Detailed Description

Serves RPCs.

Definition at line 35 of file grpc/aio/_server.py.

Constructor & Destructor Documentation

◆ __init__()

def grpc.aio._server.Server.__init__ (   self,
Optional[Executor]  thread_pool,
Optional[Sequence[grpc.GenericRpcHandler]]  generic_handlers,
Optional[Sequence[Any]]  interceptors,
ChannelArgumentType  options,
Optional[int maximum_concurrent_rpcs,
Optional[grpc.Compression compression 
)

Definition at line 38 of file grpc/aio/_server.py.

◆ __del__()

def grpc.aio._server.Server.__del__ (   self)
Schedules a graceful shutdown in current event loop.

The Cython AioServer doesn't hold a ref-count to this class. It should
be safe to slightly extend the underlying Cython object's life span.

Definition at line 162 of file grpc/aio/_server.py.

Member Function Documentation

◆ add_generic_rpc_handlers()

None grpc.aio._server.Server.add_generic_rpc_handlers (   self,
Sequence[grpc.GenericRpcHandler generic_rpc_handlers 
)
Registers GenericRpcHandlers with this Server.

This method is only safe to call before the server is started.

Args:
  generic_rpc_handlers: A sequence of GenericRpcHandlers that will be
  used to service RPCs.

Reimplemented from grpc.aio._base_server.Server.

Definition at line 59 of file grpc/aio/_server.py.

◆ add_insecure_port()

int grpc.aio._server.Server.add_insecure_port (   self,
str  address 
)
Opens an insecure port for accepting RPCs.

This method may only be called before starting the server.

Args:
  address: The address for which to open a port. If the port is 0,
    or not specified in the address, then the gRPC runtime will choose a port.

Returns:
  An integer port on which the server will accept RPC requests.

Reimplemented from grpc.aio._base_server.Server.

Definition at line 72 of file grpc/aio/_server.py.

◆ add_secure_port()

int grpc.aio._server.Server.add_secure_port (   self,
str  address,
grpc.ServerCredentials  server_credentials 
)
Opens a secure port for accepting RPCs.

This method may only be called before starting the server.

Args:
  address: The address for which to open a port.
    if the port is 0, or not specified in the address, then the gRPC
    runtime will choose a port.
  server_credentials: A ServerCredentials object.

Returns:
  An integer port on which the server will accept RPC requests.

Reimplemented from grpc.aio._base_server.Server.

Definition at line 87 of file grpc/aio/_server.py.

◆ start()

None grpc.aio._server.Server.start (   self)
Starts this Server.

This method may only be called once. (i.e. it is not idempotent).

Reimplemented from grpc.aio._base_server.Server.

Definition at line 107 of file grpc/aio/_server.py.

◆ stop()

None grpc.aio._server.Server.stop (   self,
Optional[float]  grace 
)
Stops this Server.

This method immediately stops the server from servicing new RPCs in
all cases.

If a grace period is specified, this method returns immediately and all
RPCs active at the end of the grace period are aborted. If a grace
period is not specified (by passing None for grace), all existing RPCs
are aborted immediately and this method blocks until the last RPC
handler terminates.

This method is idempotent and may be called at any time. Passing a
smaller grace value in a subsequent call will have the effect of
stopping the Server sooner (passing None will have the effect of
stopping the server immediately). Passing a larger grace value in a
subsequent call will not have the effect of stopping the server later
(i.e. the most restrictive grace value is used).

Args:
  grace: A duration of time in seconds or None.

Reimplemented from grpc.aio._base_server.Server.

Definition at line 114 of file grpc/aio/_server.py.

◆ wait_for_termination()

bool grpc.aio._server.Server.wait_for_termination (   self,
Optional[float]   timeout = None 
)
Block current coroutine until the server stops.

This is an EXPERIMENTAL API.

The wait will not consume computational resources during blocking, and
it will block until one of the two following conditions are met:

1) The server is stopped or terminated;
2) A timeout occurs if timeout is not `None`.

The timeout argument works in the same way as `threading.Event.wait()`.
https://docs.python.org/3/library/threading.html#threading.Event.wait

Args:
  timeout: A floating point number specifying a timeout for the
    operation in seconds.

Returns:
  A bool indicates if the operation times out.

Reimplemented from grpc.aio._base_server.Server.

Definition at line 138 of file grpc/aio/_server.py.

Member Data Documentation

◆ _loop

grpc.aio._server.Server._loop
private

Definition at line 39 of file grpc/aio/_server.py.

◆ _server

grpc.aio._server.Server._server
private

Definition at line 49 of file grpc/aio/_server.py.


The documentation for this class was generated from the following file:


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:32