From 05467ac5d432b825f3f314f1bcb3d596316e15e1 Mon Sep 17 00:00:00 2001 From: Joe Child Date: Mon, 2 Oct 2023 18:01:06 +0100 Subject: [PATCH] fix locking --- nameko_grpc/client.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nameko_grpc/client.py b/nameko_grpc/client.py index 224943d..3ffb88f 100644 --- a/nameko_grpc/client.py +++ b/nameko_grpc/client.py @@ -143,13 +143,14 @@ def default_compression(self): def start(self): if not self.lazy: - self._channel = self._get_channel() + self._start_channel() - def _get_channel(self): + def _start_channel(self): with self._channel_creation_lock: - channel = ClientChannel(self.target, self.ssl, self.spawn_thread) - channel.start() - return channel + if self._channel is None: + channel = ClientChannel(self.target, self.ssl, self.spawn_thread) + channel.start() + self._channel = channel def stop(self): if self._channel is not None: @@ -159,7 +160,7 @@ def stop(self): @property def channel(self): if self._channel is None: - self._channel = self._get_channel() + self._start_channel() return self._channel def timeout(self, send_stream, response_stream, deadline):