Skip to content

Commit

Permalink
fix locking
Browse files Browse the repository at this point in the history
  • Loading branch information
joechild-pace committed Oct 2, 2023
1 parent 21ebede commit 05467ac
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions nameko_grpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit 05467ac

Please sign in to comment.