From ad5fb99ea7b64e1fc7e207e526488fc2553af54e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 3 Sep 2019 11:24:15 +0100 Subject: [PATCH] Cloning the inbox thread --- inbox.py | 2 ++ threads.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/inbox.py b/inbox.py index 52eebc7c5..4a088dce4 100644 --- a/inbox.py +++ b/inbox.py @@ -1140,11 +1140,13 @@ def runInboxQueueWatchdog(projectVersion: str,httpd) -> None: """This tries to keep the inbox thread running even if it dies """ print('Starting inbox queue watchdog') + inboxQueueOriginal=httpd.thrInboxQueue.clone() httpd.thrInboxQueue.start() while True: time.sleep(20) if not httpd.thrInboxQueue.isAlive(): httpd.thrInboxQueue.kill() + httpd.thrInboxQueue=inboxQueueOriginal.clone() httpd.thrInboxQueue.start() print('Restarting inbox queue...') diff --git a/threads.py b/threads.py index d84926f7e..a93734a36 100644 --- a/threads.py +++ b/threads.py @@ -12,8 +12,9 @@ import trace import time class threadWithTrace(threading.Thread): - def __init__(self, *args, **keywords): - threading.Thread.__init__(self, *args, **keywords) + def __init__(self, *args, **keywords): + self._args, self._keywords = args, keywords + threading.Thread.__init__(self, *self._args, **self._keywords) self.killed = False def start(self): @@ -40,3 +41,8 @@ class threadWithTrace(threading.Thread): def kill(self): self.killed = True + + def clone(self): + return threadWithTrace(target=self, \ + args=(self._args, self._keywords),daemon=True) + #return threadWithTrace(self, *self._args, **self._keywords)