From 717b786256caecc4398d69277beae363183a5e74 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:57:47 -0600 Subject: [PATCH 1/3] use gevent async mode --- rootfs/webapp/acarshub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/webapp/acarshub.py b/rootfs/webapp/acarshub.py index 1bdf054b..fcf3736b 100755 --- a/rootfs/webapp/acarshub.py +++ b/rootfs/webapp/acarshub.py @@ -40,7 +40,7 @@ # regarding async_handlers=True, see: https://github.com/miguelgrinberg/Flask-SocketIO/issues/348 socketio = SocketIO( app, - async_mode=None, + async_mode="gevent", async_handlers=True, logger=False, engineio_logger=False, From b1cacfba105a22c843cc298195c9bbfbcf2fe353 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:04:21 -0600 Subject: [PATCH 2/3] Use proper checking of background thread --- rootfs/webapp/acarshub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/webapp/acarshub.py b/rootfs/webapp/acarshub.py index fcf3736b..e220ffa2 100755 --- a/rootfs/webapp/acarshub.py +++ b/rootfs/webapp/acarshub.py @@ -483,7 +483,7 @@ def init_listeners(special_message=""): thread_scheduler.start() # check if 'g' is not in thread_html_generator - if not hasattr(thread_html_generator, "g"): + if not thread_html_generator.is_alive(): acarshub_logging.log( f"{special_message}Starting htmlListener", "init", From 924e85bd90a93a4c0a0808e81eea29ed5471c731 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:13:38 -0600 Subject: [PATCH 3/3] Do stupid things to see thread status --- rootfs/webapp/acarshub.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rootfs/webapp/acarshub.py b/rootfs/webapp/acarshub.py index e220ffa2..7c36cde5 100755 --- a/rootfs/webapp/acarshub.py +++ b/rootfs/webapp/acarshub.py @@ -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 @@ -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() @@ -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(): @@ -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", @@ -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)