Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use a method rather than property #60

Merged
merged 5 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions nameko_grpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
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"