Skip to content

Commit

Permalink
Do stupid things to see thread status
Browse files Browse the repository at this point in the history
  • Loading branch information
fredclausen committed Oct 24, 2024
1 parent b1cacfb commit 924e85b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rootfs/webapp/acarshub.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
# thread for processing the incoming data

thread_html_generator = Thread()
thread_html_generator_active = False
thread_html_generator_event = Event()

# web thread
Expand Down Expand Up @@ -171,9 +172,12 @@ def getQueType(message_type):


def htmlListener():
global thread_html_generator_active
import time
import sys

thread_html_generator_active = True

# Run while requested...
while not thread_html_generator_event.is_set():
sys.stdout.flush()
Expand All @@ -190,6 +194,7 @@ def htmlListener():
acarshub_logging.log(
"Exiting HTML Listener thread", "htmlListener", level=LOG_LEVEL["DEBUG"]
)
thread_html_generator_active = False


def scheduled_tasks():
Expand Down Expand Up @@ -483,7 +488,7 @@ def init_listeners(special_message=""):
thread_scheduler.start()

# check if 'g' is not in thread_html_generator
if not thread_html_generator.is_alive():
if thread_html_generator_active is False:
acarshub_logging.log(
f"{special_message}Starting htmlListener",
"init",
Expand Down Expand Up @@ -824,7 +829,7 @@ def main_connect():
acarshub_logging.acars_traceback(e, "webapp")

# Start the htmlGenerator thread only if the thread has not been started before.
if not hasattr(thread_html_generator, "g"):
if thread_html_generator_active is False:
sys.stdout.flush()
thread_html_generator_event.clear()
thread_html_generator = socketio.start_background_task(htmlListener)
Expand Down

0 comments on commit 924e85b

Please sign in to comment.