Skip to content

Commit

Permalink
test with bug
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenc-pace committed Oct 3, 2023
1 parent 0e6a9fe commit 649eb9e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nameko_grpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def stop(self):
self._channel.stop()
self._channel = None

@property
def channel(self):
if self._channel is None:
self._start_channel()
Expand All @@ -184,7 +185,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,
Expand Down
2 changes: 2 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -414,6 +415,7 @@ class Service:
stub_cls,
compression_algorithm=compression_algorithm,
compression_level=compression_level,
lazy_startup=lazy_startup,
)

@dummy
Expand Down
14 changes: 14 additions & 0 deletions test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 649eb9e

Please sign in to comment.