Skip to content

Commit

Permalink
fix AsyncResult.get_dict for single result
Browse files Browse the repository at this point in the history
avoids issue with LoadBalancedView, client[0], etc.

Also cleanup the multiple-key test while I'm there,
because it was gross.

closes ipython#3646
  • Loading branch information
minrk committed Jul 15, 2013
1 parent 9232822 commit fae28de
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions IPython/parallel/client/asyncresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,17 @@ def get_dict(self, timeout=-1):
"""

results = self.get(timeout)
if self._single_result:
results = [results]
engine_ids = [ md['engine_id'] for md in self._metadata ]
bycount = sorted(engine_ids, key=lambda k: engine_ids.count(k))
maxcount = bycount.count(bycount[-1])
if maxcount > 1:
raise ValueError("Cannot build dict, %i jobs ran on engine #%i"%(
maxcount, bycount[-1]))

seen = set()
for engine_id in engine_ids:
if engine_id in seen:
raise ValueError("Cannot build dict, %i jobs ran on engine #%i"%(
engine_ids.count(engine_id), engine_id))
else:
seen.add(engine_id)

return dict(zip(engine_ids,results))

Expand Down

0 comments on commit fae28de

Please sign in to comment.