Skip to content

Commit

Permalink
Fix SpotWrapper.getLease implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
mhidalgo-bdai committed Mar 7, 2024
1 parent e20b28d commit 4463731
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions spot_wrapper/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,13 +996,18 @@ def takeLease(self) -> typing.Tuple[bool, typing.Optional[Lease]]:

def getLease(self) -> typing.Optional[Lease]:
"""Get a lease for the robot and keep the lease alive automatically."""
if not self._lease:
if self._use_take_lease:
self._lease = self._lease_client.take()
else:
self._lease = self._lease_client.acquire()

if self._use_take_lease:
lease = self._lease_client.take()
else:
lease = self._lease_client.acquire()
have_new_lease = (self._lease is None and lease is not None) or (
str(lease.lease_proto) != str(self._lease.lease_proto)
)
if have_new_lease:
if self._lease_keepalive is not None:
self._lease_keepalive.shutdown()
self._lease_keepalive = LeaseKeepAlive(self._lease_client)
self._lease = lease
return self._lease

def releaseLease(self) -> None:
Expand Down

0 comments on commit 4463731

Please sign in to comment.