jina.clients.grpc module

class jina.clients.grpc.GRPCClient(args=None, **kwargs)[source]

Bases: jina.clients.base.grpc.GRPCBaseClient, jina.clients.mixin.PostMixin

A client communicates the server with GRPC protocol.

class jina.clients.grpc.AsyncGRPCClient(args=None, **kwargs)[source]

Bases: jina.clients.base.grpc.GRPCBaseClient, jina.clients.mixin.AsyncPostMixin

A client communicates the server with GRPC protocol.

Unlike GRPCClient, here post() is a coroutine (i.e. declared with the async/await syntax), simply calling them will not schedule them to be executed.

To actually run a coroutine, user need to put them in an event loop, e.g. via asyncio.run(), asyncio.create_task().

AsyncGRPCClient can be very useful in the integration settings, where Jina/Flow/Client is NOT the main logic, but rather served as a part of other program. In this case, users often do not want to let Jina control the asyncio.eventloop. On contrary, Client is controlling and wrapping the event loop internally, making the Client looks synchronous from outside.