From 7a50172cc8381346c718086c2a0592756a28e2c3 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Thu, 13 Feb 2020 16:00:54 -0800 Subject: [PATCH] Handle the intercepted call case --- .../grpcio/grpc/experimental/aio/_channel.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/python/grpcio/grpc/experimental/aio/_channel.py b/src/python/grpcio/grpc/experimental/aio/_channel.py index db61bc589e8..cb4ed80339c 100644 --- a/src/python/grpcio/grpc/experimental/aio/_channel.py +++ b/src/python/grpcio/grpc/experimental/aio/_channel.py @@ -363,9 +363,21 @@ class Channel: candidate = frame.f_locals.get('self') if candidate: if isinstance(candidate, _base_call.Call): - if candidate._cython_call._channel is self._channel: - calls.append(candidate) - call_tasks.append(task) + if hasattr(candidate, '_channel'): + # For intercepted Call object + if candidate._channel is not self._channel: + continue + elif hasattr(candidate, '_cython_call'): + # For normal Call object + if candidate._cython_call._channel is not self._channel: + continue + else: + # Unidentified Call object + raise cygrpc.InternalError( + f'Unrecognized call object: {candidate}') + + calls.append(candidate) + call_tasks.append(task) # If needed, try to wait for them to finish. # Call objects are not always awaitables.