Permalink
Browse files

view.abort() aborts all outstanding tasks

Behavior now matches what docstring always claimed (default=all).
  • Loading branch information...
1 parent bdcfcc6 commit 26dd0711f8391cb294c09bc4e0badc8f18054cc4 @minrk minrk committed Dec 7, 2011
Showing with 16 additions and 2 deletions.
  1. +4 −1 IPython/parallel/client/client.py
  2. +2 −0 IPython/parallel/client/view.py
  3. +10 −1 IPython/parallel/tests/test_view.py
@@ -886,11 +886,14 @@ def abort(self, jobs=None, targets=None, block=None):
jobs : msg_id, list of msg_ids, or AsyncResult
The jobs to be aborted
-
+
+ If unspecified/None: abort all outstanding jobs.
"""
block = self.block if block is None else block
+ jobs = jobs if jobs is not None else list(self.outstanding)
targets = self._build_targets(targets)[0]
+
msg_ids = []
if isinstance(jobs, (basestring,AsyncResult)):
jobs = [jobs]
@@ -271,6 +271,8 @@ def abort(self, jobs=None, targets=None, block=None):
"""
block = block if block is not None else self.block
targets = targets if targets is not None else self.targets
+ jobs = jobs if jobs is not None else list(self.outstanding)
+
return self.client.abort(jobs=jobs, targets=targets, block=block)
def queue_status(self, targets=None, verbose=False):
@@ -292,7 +292,16 @@ def test_abort(self):
view.abort(ar3.msg_ids)
self.assertRaises(error.TaskAborted, ar2.get)
self.assertRaises(error.TaskAborted, ar3.get)
-
+
+ def test_abort_all(self):
+ """view.abort() aborts all outstanding tasks"""
+ view = self.client[-1]
+ ars = [ view.apply_async(time.sleep, 1) for i in range(10) ]
+ view.abort()
+ view.wait(timeout=5)
+ for ar in ars[5:]:
+ self.assertRaises(error.TaskAborted, ar.get)
+
def test_temp_flags(self):
view = self.client[-1]
view.block=True

0 comments on commit 26dd071

Please sign in to comment.