Skip to content

Commit

Permalink
Rough implementation of %task kill #154
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Dec 6, 2018
1 parent 74305a5 commit 3ae715d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
10 changes: 0 additions & 10 deletions src/sos_notebook/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,16 +496,6 @@ def handle_frontend_msg(msg):
self.subkernels.notify_frontend()
elif k == 'set-editor-kernel':
self.editor_kernel = v
elif k == 'kill-task':
# kill specified task
from sos.hosts import Host
Host(v[1])._task_engine.kill_tasks([v[0]])
self.send_frontend_msg('task_status',
{
'task_id': v[0],
'queue': v[1],
'status': 'abort'
})
elif k == 'cancel-workflow':
from .workflow_executor import cancel_workflow
cancel_workflow(v[0], self)
Expand Down
19 changes: 13 additions & 6 deletions src/sos_notebook/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2033,16 +2033,15 @@ def status(self, args):
try:
# return creation time, start time, and duration
tid, tags, _, tst = line.split('\t')
env.tapping_listener_socket.send_pyobj({
'msg_type': 'task_status',
'data': {
self.sos_kernel.send_frontend_msg('task_status',
{
'update_only': True,
'queue': args.queue,
'task_id': tid,
'status': tst,
'tags': tags
}
})
)
except Exception as e:
env.logger.warning(
f'Unrecognized response "{line}" ({e.__class__.__name__}): {e}')
Expand All @@ -2052,8 +2051,16 @@ def resume(self, args):
return

def kill(self, args):
self.sos_kernel.warn(args)
return
# kill specified task
from sos.hosts import Host
Host(args.queue)._task_engine.kill_tasks(args.tasks)
for tid in args.tasks:
self.sos_kernel.send_frontend_msg('task_status',
{
'task_id': tid,
'queue': args.queue,
'status': 'abort'
})

def purge(self, args):
self.sos_kernel.warn(args)
Expand Down

0 comments on commit 3ae715d

Please sign in to comment.