grpc: Cannot set custom data to `_ServiceContext` in aio grpc server interceptor
Hi! Recently I’ve switched to aio version of grpc and started rewriting our code. I came across a problem with server interceptors: it’s impossible to add any kind of information to passed context! We use context for opentracing context e.g. After income metadata is processed we set span
attribute to context in interceptor handler:
context.span = span
But it doesn’t work anymore. Even setattr
doesn’t work. I think this is a bug.
Or is there any other way to set a custom data to _ServicerContext
instance?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (8 by maintainers)
Commits related to this issue
- [Python fix-it][Aysnc Example] Adding examples for aysnc interceptor context propagaton (#32840) ### Description Fix https://github.com/grpc/grpc/issues/24470. Adding one example which demonstr... — committed to grpc/grpc by XuanWang-Amos a year ago
- [Python fix-it][Aysnc Example] Adding examples for aysnc interceptor context propagaton (#32840) ### Description Fix https://github.com/grpc/grpc/issues/24470. Adding one example which demonstr... — committed to nanahpang/grpc by XuanWang-Amos a year ago
- [Python fix-it][Aysnc Example] Adding examples for aysnc interceptor context propagaton (#32840) ### Description Fix https://github.com/grpc/grpc/issues/24470. Adding one example which demonstr... — committed to grpc/grpc by XuanWang-Amos a year ago
We talked internally and decided that we need to change the behavior of the sync implementation first (interceptors and handler should run in the same thread). Once we do that, we can add an example.
This is not a small change, and it’s not urgent. We have other priorities right now so it might take a while. If you want this change sooner, please comment or give a 👍 here.
To anyone who’s interested, we plan to add those examples by end of April 14.