Skip to content

Commit

Permalink
🐛 wrap land and streamoff calls in a try-catch in the end function to…
Browse files Browse the repository at this point in the history
… prevent raising an exception when the drone crashed (closes #126)
  • Loading branch information
M4GNV5 committed Feb 18, 2022
1 parent 0636287 commit 5c5848f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions djitellopy/tello.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,10 +993,14 @@ def query_active(self) -> str:
def end(self):
"""Call this method when you want to end the tello object
"""
if self.is_flying:
self.land()
if self.stream_on:
self.streamoff()
try:
if self.is_flying:
self.land()
if self.stream_on:
self.streamoff()
except TelloException:
pass

if self.background_frame_read is not None:
self.background_frame_read.stop()

Expand Down

0 comments on commit 5c5848f

Please sign in to comment.