diff --git a/nameko_grpc/client.py b/nameko_grpc/client.py index 89b40d2..8885c40 100644 --- a/nameko_grpc/client.py +++ b/nameko_grpc/client.py @@ -163,7 +163,6 @@ def stop(self): self._channel.stop() self._channel = None - @property def channel(self): if self._channel is None: self._start_channel() @@ -185,7 +184,7 @@ def timeout(self, send_stream, response_stream, deadline): time.sleep(0.001) def invoke(self, request_headers, request, timeout): - send_stream, response_stream = self.channel.send_request(request_headers) + send_stream, response_stream = self.channel().send_request(request_headers) if timeout: self.spawn_thread( target=self.timeout, diff --git a/setup.py b/setup.py index 6ee3c5c..503a315 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( name="nameko-grpc", - version="1.4.0rc1", + version="1.4.0rc2", description="Nameko gRPC extensions", long_description=readme, long_description_content_type="text/markdown", diff --git a/test/conftest.py b/test/conftest.py index 2b22c0e..61947a0 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -399,6 +399,7 @@ def make( proto_name=None, compression_algorithm="none", compression_level="high", + lazy_startup=False, ): if proto_name is None: proto_name = service_name @@ -414,6 +415,7 @@ class Service: stub_cls, compression_algorithm=compression_algorithm, compression_level=compression_level, + lazy_startup=lazy_startup, ) @dummy diff --git a/test/test_basic.py b/test/test_basic.py index dc5eb30..bf8263d 100644 --- a/test/test_basic.py +++ b/test/test_basic.py @@ -136,3 +136,17 @@ def test_lazy_client_does_not_connect_on_start( def test_nonlazy_client_connects_on_start(self, start_nameko_client, protobufs): with pytest.raises(ConnectionRefusedError): start_nameko_client("example", lazy_startup=False) + + def test_lazy_client_with_with_dependency_provider( + self, start_dependency_provider, protobufs, start_grpc_server + ): + client = start_dependency_provider("example", lazy_startup=True) + + with pytest.raises(ConnectionRefusedError): + client.unary_unary(protobufs.ExampleRequest(value="A")) + + start_grpc_server("example") + + # After starting the server, should now work + response = client.unary_unary(protobufs.ExampleRequest(value="A")) + assert response.message == "A"