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?

https://github.com/grpc/grpc/blob/master/src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi#L113

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (8 by maintainers)

Commits related to this issue

Most upvoted comments

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.