python-grpc icon indicating copy to clipboard operation
python-grpc copied to clipboard

cannot use intercept_channel with `with` statement

Open wtnb75 opened this issue 5 years ago • 0 comments

grpc channel is usually used with with statement like here -> https://github.com/grpc/grpc/blob/master/examples/python/helloworld/greeter_client_with_options.py#L31

but...

import opentracing
from grpc_opentracing import open_tracing_client_interceptor
from grpc_opentracing.grpcext import intercept_channel
from grpc import insecure_channel

ic = open_tracing_client_interceptor(opentracing.global_tracer())
with intercept_channel(insecure_channel("localhost:5000"), ic) as ch:
  pass  # blabla
Traceback (most recent call last):
  File "testwith.py", line 7, in <module>
    with intercept_channel(insecure_channel("localhost:5000"), ic) as ch:
AttributeError: __enter__

wtnb75 avatar Feb 26 '20 07:02 wtnb75