Skip to content

Commit

Permalink
Prevent lease acquisition after disconnection
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 25, 2024
1 parent e238ad8 commit 12a9f39
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spot_wrapper/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,9 @@ def robotToLocalTime(self, timestamp: Timestamp) -> Timestamp:

def claim(self) -> typing.Tuple[bool, str]:
"""Get a lease for the robot, a handle on the estop endpoint, and the ID of the robot."""
if not self._valid:
return False, "Wrapper is not valid"

if self.lease is not None:
for resource in self.lease:
if resource.resource == "all-leases" and SPOT_CLIENT_NAME in resource.lease_owner.client_name:
Expand Down Expand Up @@ -1029,6 +1032,7 @@ def release(self) -> typing.Tuple[bool, str]:

def disconnect(self) -> None:
"""Release control of robot as gracefully as posssible."""
self._valid = False
if self._robot.time_sync:
self._robot.time_sync.stop()
self.releaseLease()
Expand Down

0 comments on commit 12a9f39

Please sign in to comment.