From 04b4db64ec1af6e8a2ec54698069827c62b83bdc Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Fri, 15 Dec 2023 13:30:39 +0100 Subject: [PATCH] Log memory errors when to debug level --- wakaq/worker.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wakaq/worker.py b/wakaq/worker.py index 567b1e4..df921d9 100644 --- a/wakaq/worker.py +++ b/wakaq/worker.py @@ -49,6 +49,7 @@ def __init__(self, pid, stdin, pingin, broadcastout): os.set_blocking(stdin, False) os.set_blocking(pingin, False) os.set_blocking(broadcastout, False) + self.current_task = None self.pid = pid self.stdin = stdin self.pingin = pingin @@ -259,8 +260,8 @@ def _child(self, stdout, pingout, broadcastin): except: # give task back to queue so it's not lost self.wakaq.broker.lpush(queue_broker_key, serialize(payload)) - self._stop_processing = True - return + current_task.set(None) + raise try: self._execute_task(task, payload, queue=queue) @@ -324,6 +325,11 @@ def _child(self, stdout, pingout, broadcastin): if current_task.get(): raise + except (MemoryError, BlockingIOError): + if current_task.get(): + raise + log.debug(traceback.format_exc()) + except Exception as e: if exception_in_chain(e, SoftTimeout): if current_task.get():