##// END OF EJS Templates
fix %px magic output for single target...
MinRK -
Show More
@@ -92,7 +92,7 b' class ParalleMagic(Plugin):'
92 92 Then you can do the following::
93 93
94 94 In [24]: %px a = 5
95 Parallel execution on engines: all
95 Parallel execution on engine(s): all
96 96 Out[24]:
97 97 <Results List>
98 98 [0] In [7]: a = 5
@@ -102,7 +102,7 b' class ParalleMagic(Plugin):'
102 102 if self.active_view is None:
103 103 print NO_ACTIVE_VIEW
104 104 return
105 print "Parallel execution on engines: %s" % self.active_view.targets
105 print "Parallel execution on engine(s): %s" % self.active_view.targets
106 106 result = self.active_view.execute(parameter_s, block=False)
107 107 if self.active_view.block:
108 108 result.get()
@@ -125,9 +125,9 b' class ParalleMagic(Plugin):'
125 125 %autopx to enabled
126 126
127 127 In [26]: a = 10
128 Parallel execution on engines: [0,1,2,3]
128 Parallel execution on engine(s): [0,1,2,3]
129 129 In [27]: print a
130 Parallel execution on engines: [0,1,2,3]
130 Parallel execution on engine(s): [0,1,2,3]
131 131 [stdout:0] 10
132 132 [stdout:1] 10
133 133 [stdout:2] 10
@@ -174,15 +174,21 b' class ParalleMagic(Plugin):'
174 174 If self.active_view.block is True, wait for the result
175 175 and display the result. Otherwise, this is a noop.
176 176 """
177 if isinstance(result.stdout, basestring):
178 # single result
179 stdouts = [result.stdout.rstrip()]
180 else:
181 stdouts = [s.rstrip() for s in result.stdout]
182
177 183 targets = self.active_view.targets
178 184 if isinstance(targets, int):
179 185 targets = [targets]
180 if targets == 'all':
186 elif targets == 'all':
181 187 targets = self.active_view.client.ids
182 stdout = [s.rstrip() for s in result.stdout]
183 if any(stdout):
184 for i,eid in enumerate(targets):
185 print '[stdout:%i]'%eid, stdout[i]
188
189 if any(stdouts):
190 for eid,stdout in zip(targets, stdouts):
191 print '[stdout:%i]'%eid, stdout
186 192
187 193
188 194 def pxrun_cell(self, raw_cell, store_history=True):
@@ -315,6 +315,7 b' class TestView(ClusterTestCase):'
315 315 sys.stdout = savestdout
316 316 sio.read()
317 317 self.assertTrue('[stdout:%i]'%v.targets in sio.buf)
318 self.assertTrue(sio.buf.rstrip().endswith('10'))
318 319 self.assertRaisesRemote(ZeroDivisionError, ip.magic_px, '1/0')
319 320
320 321 def test_magic_px_nonblocking(self):
General Comments 0
You need to be logged in to leave comments. Login now