#🔒 Grpc Python help
24 messages · Page 1 of 1 (latest)
@covert juniper
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
try:
updated_call_details = grpc.HandlerCallDetails(
method=handler_call_details.method,
invocation_metadata=new_metadata,
)
except Exception as e:
print(e)
raise e
apparently you cant create a new handlerCalldetails
HandlerCallDetails() takes no arguments
this is the error
specifically
HandlerCallDetails is defined as an ABC (Abstract Base Model), so that makes sense.
This example in the grpc repo may help:
https://github.com/grpc/grpc/blob/ba9b36ff028404ac3167219086ab4bb23594ae89/examples/python/interceptors/headers/header_manipulator_client_interceptor.py
lemme check
The above is actually used in an example like so: https://github.com/grpc/grpc/blob/ba9b36ff028404ac3167219086ab4bb23594ae89/examples/python/interceptors/headers/greeter_client.py#L26-L42
this is on the client side if i understand correctly?
i am trying to manipulate on the server side
True. Look nearby in the same example directory.
https://github.com/grpc/grpc/blob/ba9b36ff028404ac3167219086ab4bb23594ae89/examples/python/interceptors/headers/greeter_server.py#L32-L46
yup checking there
It creates a grpc.server with a tuple of interceptors, and includes the header_validator.
Kind of confusing to me how it's set up, but the source of that validator is here:
https://github.com/grpc/grpc/blob/master/examples/python/interceptors/headers/request_header_validator_interceptor.py
Basically it's a class you create that inherits grpc.ServerInterceptor, has a def intercept_service method defined, and then does things to its handler_call_details argument.
As you find, you don't create the details: they are passed to this method as an arg.
lemme check
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.