Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions radio/app/drone.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
from queue import Empty, Queue
from secrets import token_hex
from threading import Event, Lock, Thread
from threading import Event, Lock, Thread, current_thread
from typing import Callable, Dict, List, Optional

import serial
Expand Down Expand Up @@ -672,11 +672,17 @@ def stopAllThreads(self) -> None:
self.is_active.clear()
self.is_listening = False

self.listener_thread.join(timeout=3)
self.sender_thread.join(timeout=3)
self.log_thread.join(timeout=3)
self.link_debug_data_thread.join(timeout=3)
self.heartbeat_thread.join(timeout=3)
this_thread = current_thread()

for thread in [
getattr(self, "listener_thread", None),
getattr(self, "sender_thread", None),
getattr(self, "log_thread", None),
getattr(self, "link_debug_data_thread", None),
getattr(self, "heartbeat_thread", None),
]:
if thread is not None and thread.is_alive() and thread is not this_thread:
thread.join(timeout=3)

def rebootAutopilot(self) -> None:
"""Reboot the autopilot."""
Expand Down
Loading