[Aio] Attempt to fix recent AsyncIO windows flake
diff --git a/src/python/grpcio/grpc/experimental/aio/_channel.py b/src/python/grpcio/grpc/experimental/aio/_channel.py
index 65a4421..5d30e23 100644
--- a/src/python/grpcio/grpc/experimental/aio/_channel.py
+++ b/src/python/grpcio/grpc/experimental/aio/_channel.py
@@ -44,7 +44,10 @@
self._calls = WeakSet()
def _remove_call(self, call: _base_call.RpcContext):
- self._calls.remove(call)
+ try:
+ self._calls.remove(call)
+ except KeyError:
+ pass
@property
def calls(self) -> AbstractSet[_base_call.RpcContext]:
diff --git a/src/python/grpcio_tests/tests_aio/unit/close_channel_test.py b/src/python/grpcio_tests/tests_aio/unit/close_channel_test.py
index b749603..f7d9de5 100644
--- a/src/python/grpcio_tests/tests_aio/unit/close_channel_test.py
+++ b/src/python/grpcio_tests/tests_aio/unit/close_channel_test.py
@@ -24,11 +24,11 @@
from grpc.experimental.aio._channel import _OngoingCalls
from src.proto.grpc.testing import messages_pb2, test_pb2_grpc
-from tests_aio.unit._constants import UNARY_CALL_WITH_SLEEP_VALUE
from tests_aio.unit._test_base import AioTestBase
from tests_aio.unit._test_server import start_test_server
_UNARY_CALL_METHOD_WITH_SLEEP = '/grpc.testing.TestService/UnaryCallWithSleep'
+_LONG_TIMEOUT_THAT_SHOULD_NOT_EXPIRE = 60
class TestOngoingCalls(unittest.TestCase):
@@ -90,7 +90,7 @@
call = UnaryCallWithSleep(messages_pb2.SimpleRequest())
- await channel.close(grace=UNARY_CALL_WITH_SLEEP_VALUE * 4)
+ await channel.close(grace=_LONG_TIMEOUT_THAT_SHOULD_NOT_EXPIRE)
self.assertEqual(grpc.StatusCode.OK, await call.code())