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

Public Member Functions

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)
 

Detailed Description

Serves RPCs.

Definition at line 28 of file _base_server.py.

Member Function Documentation

◆ add_generic_rpc_handlers()

None grpc.aio._base_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 in grpc.aio._server.Server.

Definition at line 32 of file _base_server.py.

◆ add_insecure_port()

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

A port is a communication endpoint that used by networking protocols,
like TCP and UDP. To date, we only support TCP.

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 in grpc.aio._server.Server.

Definition at line 45 of file _base_server.py.

◆ add_secure_port()

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

A port is a communication endpoint that used by networking protocols,
like TCP and UDP. To date, we only support TCP.

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 in grpc.aio._server.Server.

Definition at line 62 of file _base_server.py.

◆ start()

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

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

Reimplemented in grpc.aio._server.Server.

Definition at line 82 of file _base_server.py.

◆ stop()

None grpc.aio._base_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 in grpc.aio._server.Server.

Definition at line 89 of file _base_server.py.

◆ wait_for_termination()

bool grpc.aio._base_server.Server.wait_for_termination (   self,
Optional[float]   timeout = None 
)
Continues current coroutine once 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 in grpc.aio._server.Server.

Definition at line 113 of file _base_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