How to use the grpclib.const.Status.UNIMPLEMENTED function in grpclib

To help you get started, we’ve selected a few grpclib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vmagamedov / grpclib / tests / test_server_events.py View on Github external
async def StreamUnary(self, stream):
        raise GRPCError(Status.UNIMPLEMENTED)
github vmagamedov / grpclib / tests / test_stats.py View on Github external
async def UnaryUnary(self, stream):
        raise GRPCError(Status.UNIMPLEMENTED)
github vmagamedov / grpclib / tests / test_server_events.py View on Github external
async def UnaryStream(self, stream):
        raise GRPCError(Status.UNIMPLEMENTED)
github vmagamedov / grpclib / tests / test_memory.py View on Github external
async def UnaryStream(self, stream):
        raise GRPCError(Status.UNIMPLEMENTED)
github vmagamedov / grpclib / tests / test_stats.py View on Github external
async def StreamUnary(self, stream):
        raise GRPCError(Status.UNIMPLEMENTED)
github vmagamedov / grpclib / tests / test_client_stream.py View on Github external
async def test_unimplemented_error(cs: ClientStream):
    with pytest.raises(ErrorDetected):
        async with cs.client_stream as stream:
            await stream.send_request()

            events = cs.client_conn.to_server_transport.events()
            stream_id = events[-1].stream_id

            cs.client_conn.server_h2c.send_headers(stream_id, [
                (':status', '200'),
                ('content-type', 'application/grpc+proto'),
                ('grpc-status', str(Status.UNIMPLEMENTED.value)),
            ], end_stream=True)
            cs.client_conn.server_flush()

            try:
                await stream.recv_initial_metadata()
            except GRPCError as exc:
                assert exc and exc.status == Status.UNIMPLEMENTED
                raise ErrorDetected()
github vmagamedov / grpclib / tests / test_client_events.py View on Github external
async def StreamStream(self, stream):
        raise GRPCError(Status.UNIMPLEMENTED)
github vmagamedov / grpclib / tests / test_client_stream.py View on Github external
with pytest.raises(GRPCError) as err:
        async with cs.client_stream as stream:
            await stream.send_request()

            events = cs.client_conn.to_server_transport.events()
            stream_id = events[-1].stream_id

            cs.client_conn.server_h2c.send_headers(stream_id, [
                (':status', '200'),
                ('content-type', 'application/grpc+proto'),
                ('grpc-status', str(Status.UNIMPLEMENTED.value)),
            ], end_stream=True)
            cs.client_conn.server_h2c.reset_stream(stream_id)
            cs.client_conn.server_flush()

    assert err.value.status == Status.UNIMPLEMENTED
github vmagamedov / grpclib / grpclib / client.py View on Github external
if TYPE_CHECKING:
    from ._typing import IReleaseStream  # noqa


_H2_OK = '200'

# https://github.com/grpc/grpc/blob/master/doc/http-grpc-status-mapping.md
_H2_TO_GRPC_STATUS_MAP = {
    # 400
    str(http.HTTPStatus.BAD_REQUEST.value): Status.INTERNAL,
    # 401
    str(http.HTTPStatus.UNAUTHORIZED.value): Status.UNAUTHENTICATED,
    # 403
    str(http.HTTPStatus.FORBIDDEN.value): Status.PERMISSION_DENIED,
    # 404
    str(http.HTTPStatus.NOT_FOUND.value): Status.UNIMPLEMENTED,
    # 502
    str(http.HTTPStatus.BAD_GATEWAY.value): Status.UNAVAILABLE,
    # 503
    str(http.HTTPStatus.SERVICE_UNAVAILABLE.value): Status.UNAVAILABLE,
    # 504
    str(http.HTTPStatus.GATEWAY_TIMEOUT.value): Status.UNAVAILABLE,
    # 429
    str(http.HTTPStatus.TOO_MANY_REQUESTS.value): Status.UNAVAILABLE,
}


class Handler(AbstractHandler):
    connection_lost = False

    def accept(self, stream: Any, headers: Any, release_stream: Any) -> None:
        raise NotImplementedError('Client connection can not accept requests')
github facebook / idb / idb / ipc / boot.py View on Github external
async def daemon(
    context: DaemonContext, client: CompanionClient, request: BootRequest
) -> BootResponse:
    if client.is_companion_available:
        await none_throws(context.boot_manager).boot(udid=none_throws(client.udid))
        return BootResponse()
    else:
        # TODO T41660845
        raise GRPCError(
            status=Status(Status.UNIMPLEMENTED),
            message="boot with chained daemons hasn't been implemented yet",
        )