From 7d08ffdeb80d4bac1cf0a25d6452194bcdd843b4 2011-04-08 00:38:14 From: MinRK Date: 2011-04-08 00:38:14 Subject: [PATCH] protect LBView.targets, AsyncResult._msg_ids -> .msg_ds --- diff --git a/IPython/zmq/parallel/asyncresult.py b/IPython/zmq/parallel/asyncresult.py index 869c2c2..0031ce1 100644 --- a/IPython/zmq/parallel/asyncresult.py +++ b/IPython/zmq/parallel/asyncresult.py @@ -23,7 +23,7 @@ class AsyncResult(object): """ def __init__(self, client, msg_ids): self._client = client - self._msg_ids = msg_ids + self.msg_ids = msg_ids self._ready = False self._success = None @@ -31,7 +31,7 @@ class AsyncResult(object): if self._ready: return "<%s: finished>"%(self.__class__.__name__) else: - return "<%s: %r>"%(self.__class__.__name__,self._msg_ids) + return "<%s: %r>"%(self.__class__.__name__,self.msg_ids) def _reconstruct_result(self, res): @@ -74,10 +74,10 @@ class AsyncResult(object): """ if self._ready: return - self._ready = self._client.barrier(self._msg_ids, timeout) + self._ready = self._client.barrier(self.msg_ids, timeout) if self._ready: try: - results = map(self._client.results.get, self._msg_ids) + results = map(self._client.results.get, self.msg_ids) results = error.collect_exceptions(results, 'get') self._result = self._reconstruct_result(results) except Exception, e: diff --git a/IPython/zmq/parallel/client.py b/IPython/zmq/parallel/client.py index 5db9882..3b9df47 100644 --- a/IPython/zmq/parallel/client.py +++ b/IPython/zmq/parallel/client.py @@ -504,7 +504,7 @@ class Client(object): if isinstance(msg_id, int): msg_id = self.history[msg_id] elif isinstance(msg_id, AsyncResult): - map(theids.add, msg_id._msg_ids) + map(theids.add, msg_id.msg_ids) continue theids.add(msg_id) if not theids.intersection(self.outstanding): @@ -849,7 +849,7 @@ class Client(object): r = self.push({key: partition[0]}, targets=engineid, block=False) else: r = self.push({key: partition}, targets=engineid, block=False) - msg_ids.extend(r._msg_ids) + msg_ids.extend(r.msg_ids) r = AsyncResult(self, msg_ids) if block: return r.get() @@ -866,7 +866,7 @@ class Client(object): mapObject = Map.dists[dist]() msg_ids = [] for index, engineid in enumerate(targets): - msg_ids.extend(self.pull(key, targets=engineid,block=False)._msg_ids) + msg_ids.extend(self.pull(key, targets=engineid,block=False).msg_ids) r = AsyncMapResult(self, msg_ids, mapObject) if block: diff --git a/IPython/zmq/parallel/view.py b/IPython/zmq/parallel/view.py index b597eec..305c794 100644 --- a/IPython/zmq/parallel/view.py +++ b/IPython/zmq/parallel/view.py @@ -344,4 +344,12 @@ class LoadBalancedView(View): def __repr__(self): return "<%s %s>"%(self.__class__.__name__, self.client._addr) + @property + def targets(self): + return None + + @targets.setter + def targets(self, value): + raise AttributeError("Cannot set targets for LoadbalancedView!") + \ No newline at end of file