From 753c10d3638c94f1b93aad23cd2665675f6c31df 2013-01-06 22:20:33 From: MinRK Date: 2013-01-06 22:20:33 Subject: [PATCH] %%px --local runs local last ensures concurrent execution of all n+1 executions --- diff --git a/IPython/parallel/client/magics.py b/IPython/parallel/client/magics.py index 65f9701..4cf7bff 100644 --- a/IPython/parallel/client/magics.py +++ b/IPython/parallel/client/magics.py @@ -294,16 +294,26 @@ class ParallelMagics(Magics): if args.targets: save_targets = self.view.targets self.view.targets = self._eval_target_str(args.targets) - if args.local: - self.shell.run_cell(cell) + # if running local, don't block until after local has run + block = False if args.local else args.block try: - return self.parallel_execute(cell, block=args.block, + ar = self.parallel_execute(cell, block=block, groupby=args.groupby, save_name=args.save_name, ) finally: if args.targets: self.view.targets = save_targets + + # run locally after submitting remote + if args.local: + self.shell.run_cell(cell) + # now apply blocking behavor to remote execution + block = self.view.block if args.block is None else args.block + if block: + ar.get() + ar.display_outputs(groupby) + return ar @skip_doctest def autopx(self, line=''):