From 285d845acd16637f0baf94f58d5ff3dd551e3b76 Mon Sep 17 00:00:00 2001
From: Amir MOHAMMADI <amir.mohammadi@idiap.ch>
Date: Mon, 9 Sep 2019 10:49:47 +0200
Subject: [PATCH 1/2] Refresh the status of jobs from SGE before listing them

---
 gridtk/script/jman.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gridtk/script/jman.py b/gridtk/script/jman.py
index be55011..6de2712 100644
--- a/gridtk/script/jman.py
+++ b/gridtk/script/jman.py
@@ -205,6 +205,9 @@ def run_scheduler(args):
 def list(args):
   """Lists the jobs in the given database."""
   jm = setup(args)
+  if not args.local:
+    # update the status of jobs from SGE before listing them.
+    jm.communicate(job_ids=get_ids(args.job_ids))
   jm.list(job_ids=get_ids(args.job_ids), print_array_jobs=args.print_array_jobs, print_dependencies=args.print_dependencies, status=args.status, long=args.long, print_times=args.print_times, ids_only=args.ids_only, names=args.names)
 
 
-- 
GitLab


From 7b0c44f1e349d44b4d9c0acbff77df92bec89d9c Mon Sep 17 00:00:00 2001
From: Amir MOHAMMADI <amir.mohammadi@idiap.ch>
Date: Mon, 9 Sep 2019 10:50:16 +0200
Subject: [PATCH 2/2] Allow failed jobs to be stopped too (changing their
 status to submitted)

---
 gridtk/sge.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gridtk/sge.py b/gridtk/sge.py
index 2d5255c..95945da 100644
--- a/gridtk/sge.py
+++ b/gridtk/sge.py
@@ -200,7 +200,7 @@ class JobManagerSGE(JobManager):
       if job.status in ('executing', 'queued', 'waiting'):
         qdel(job.id, context=self.context)
         logger.info("Stopped job '%s' in the SGE grid." % job)
-        job.submit()
+      job.submit()
 
       self.session.commit()
     self.unlock()
-- 
GitLab