Skip to content

Commit

Permalink
more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankrb committed Jul 18, 2024
1 parent 73a65f1 commit 08cf6c5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/anemoi/registry/workers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,23 @@ def run(self):
def process_one_task(self):
task = self.choose_task()
if not task:
return False
return

uuid = task.key
LOG.info(f"Processing task {uuid}: {task}")
self.parse_task(task) # for checking only

task.take_ownership()
self.process_task_with_heartbeat(task)
try:
self.process_task_with_heartbeat(task)
except Exception as e:
LOG.error(f"Error for task {task}: {e}")
LOG.exception("Exception occurred during task processing:", exc_info=e)
task.release_ownership()
return
LOG.info(f"Task {uuid} completed.")
task.unregister()
LOG.info(f"Task {uuid} deleted.")
return True

def process_task_with_heartbeat(self, task):
STOP = []
Expand Down Expand Up @@ -149,7 +154,7 @@ def choose_task(self):
if not cat:
LOG.info("No queued tasks found")
else:
LOG.info(cat.to_str(long=True))
LOG.info(f"Tasks list \n{cat.to_str(long=True)}")

# if a task is running, check if it has been running for too long, and free it
for task in cat:
Expand Down

0 comments on commit 08cf6c5

Please sign in to comment.