cli/list-tasks: show more information for the abort case
4 files changed, 20 insertions(+), 8 deletions(-)

M rework/cli.py
M rework/monitor.py
M rework/task.py
M tests/test_cli.py
M rework/cli.py +10 -3
@@ 291,8 291,11 @@ def list_tasks(dburi, tracebacks=False, 
     init()
     engine = create_engine(find_dburi(dburi))
     opmap = dict(engine.execute('select id, name from rework.operation').fetchall())
-    sql = ('select id from rework.task order by id')
-    for tid, in engine.execute(sql):
+    sql = ('select t.id, w.deathinfo, w.mem '
+           'from rework.task as t left outer join rework.worker as w '
+           'on t.worker = w.id '
+           'order by id')
+    for tid, di, mem in engine.execute(sql):
         task = Task.byid(engine, tid)
         stat = task.state
         print(Style.RESET_ALL + str(tid),

          
@@ 318,6 321,10 @@ def list_tasks(dburi, tracebacks=False, 
 
         if tracebacks and task.traceback:
             print(Fore.YELLOW + task.traceback, end='')
+
+        if di:
+            print(Fore.YELLOW + di, end=' ')
+            print(Fore.YELLOW + str(mem), end='')
         print()
 
 

          
@@ 362,7 369,7 @@ def abort_task(dburi, taskid):
     """
     engine = create_engine(find_dburi(dburi))
     task = Task.byid(engine, taskid)
-    task.abort()
+    task.abort('from the command line')
 
 
 @rework.command(name='list-scheduled')

          
M rework/monitor.py +1 -1
@@ 321,7 321,7 @@ class Monitor:
                 delta = parse_delta(timeout)
                 now = utcnow()
                 if (now - start_time) > delta:
-                    Task.byid(self.engine, tid).abort()
+                    Task.byid(self.engine, tid).abort('timeout')
 
     def track_starting(self):
         if not self.pending_start:

          
M rework/task.py +3 -2
@@ 367,7 367,7 @@ class Task:
                 status='done'
             ).do(cn)
 
-    def abort(self):
+    def abort(self, msg='<no known cause>'):
         """ask the abortion of the task
 
         The effective abortion will be done by the responsible monitor

          
@@ 395,5 395,6 @@ class Task:
                 'worker.id = task.worker',
                 'task.id = %(id)s', id=self.tid
             ).values(
-                kill=True
+                kill=True,
+                deathinfo=msg
             ).do(cn)

          
M tests/test_cli.py +6 -2
@@ 412,7 412,9 @@ def test_abort_task(engine, cli, cleanup
             '<X> infinite_loop aborted '
             '[<X>-<X>-<X> <X>:<X>:<X>.<X>UTC] → '
             '[<X>-<X>-<X> <X>:<X>:<X>.<X>UTC] → '
-            '[<X>-<X>-<X> <X>:<X>:<X>.<X>UTC]'
+            '[<X>-<X>-<X> <X>:<X>:<X>.<X>UTC] '
+            'preemptive kill at '
+            '<X>-<X>-<X> <X>:<X>:<X>.<X>+<X>:<X> <X>'
         ) == scrub(r.output)
 
 

          
@@ 441,7 443,9 @@ def test_kill_worker(engine, cli, cleanu
             '<X> infinite_loop aborted '
             '[<X>-<X>-<X> <X>:<X>:<X>.<X>UTC] → '
             '[<X>-<X>-<X> <X>:<X>:<X>.<X>UTC] → '
-            '[<X>-<X>-<X> <X>:<X>:<X>.<X>UTC]'
+            '[<X>-<X>-<X> <X>:<X>:<X>.<X>UTC] '
+            'preemptive kill at '
+            '<X>-<X>-<X> <X>:<X>:<X>.<X>+<X>:<X> <X>'
         ) == scrub(r.output)