Fix posts watchdog

main
bashrc 2026-04-13 11:12:37 +01:00
parent a679ebdeae
commit a4a17d2fbf
1 changed files with 11 additions and 6 deletions

View File

@ -532,20 +532,22 @@ def run_shares_expire(version_number: str, base_dir: str, httpd) -> None:
httpd.person_cache) httpd.person_cache)
def run_posts_watchdog(project_version: str, httpd) -> None: def run_posts_watchdog(base_dir: str, send_threads: [], debug: bool,
timeout_mins: int, httpd) -> None:
"""This tries to keep the posts thread running even if it dies """This tries to keep the posts thread running even if it dies
""" """
print('THREAD: Starting posts queue watchdog') print('THREAD: Starting posts queue watchdog')
posts_queue_original = httpd.thrPostsQueue.clone(run_posts_queue)
begin_thread(httpd.thrPostsQueue, 'run_posts_watchdog')
while True: while True:
time.sleep(20) time.sleep(20)
if httpd.thrPostsQueue.is_alive(): if httpd.thrPostsQueue.is_alive():
continue continue
httpd.thrPostsQueue.kill() httpd.thrPostsQueue.kill()
print('THREAD: restarting posts queue') print('THREAD: restarting posts queue')
httpd.thrPostsQueue = posts_queue_original.clone(run_posts_queue) httpd.thrPostsQueue = \
begin_thread(httpd.thrPostsQueue, 'run_posts_watchdog 2') thread_with_trace(target=run_posts_queue,
args=(base_dir, send_threads, debug,
timeout_mins),
daemon=True)
print('Restarting posts queue...') print('Restarting posts queue...')
@ -1296,7 +1298,10 @@ def run_daemon(accounts_data_dir: str,
print('THREAD: run_posts_watchdog') print('THREAD: run_posts_watchdog')
httpd.thrPostsWatchdog = \ httpd.thrPostsWatchdog = \
thread_with_trace(target=run_posts_watchdog, thread_with_trace(target=run_posts_watchdog,
args=(project_version, httpd), daemon=True) args=(base_dir, httpd.send_threads, debug,
httpd.send_threads_timeout_mins,
httpd),
daemon=True)
begin_thread(httpd.thrPostsWatchdog, 'run_daemon thrPostWatchdog') begin_thread(httpd.thrPostsWatchdog, 'run_daemon thrPostWatchdog')
else: else:
begin_thread(httpd.thrPostsQueue, 'run_daemon thrPostWatchdog 2') begin_thread(httpd.thrPostsQueue, 'run_daemon thrPostWatchdog 2')