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.