environment/lib/python2.7/site-packages/IPython/parallel/controller/hub.py
def get_results(self, client_id, msg):
        """Get the result of 1 or more messages."""
        content = msg['content']
        msg_ids = sorted(set(content['msg_ids']))
        statusonly = content.get('status_only', False)
        pending = []
        completed = []
        content = dict(status='ok')
        content['pending'] = pending
        content['completed'] = completed
        buffers = []
        if not statusonly:
            try:
                matches = self.db.find_records(dict(msg_id={'$in':msg_ids}))
                # turn match list into dict, for faster lookup
                records = {}
                for rec in matches:
                    records[rec['msg_id']] = rec
            except Exception:
                content = error.wrap_exception()
                self.session.send(self.query, "result_reply", content=content,
                                                    parent=msg, ident=client_id)
                return
        else:
            records = {}
        for msg_id in msg_ids:
            if msg_id in self.pending:
                pending.append(msg_id)
            elif msg_id in self.all_completed:
                completed.append(msg_id)
                if not statusonly:
                    c,bufs = self._extract_record(records[msg_id])
                    content[msg_id] = c
                    buffers.extend(bufs)
            elif msg_id in records:
                if rec['completed']:
                    completed.append(msg_id)
                    c,bufs = self._extract_record(records[msg_id])
                    content[msg_id] = c
                    buffers.extend(bufs)
                else:
                    pending.append(msg_id)
            else:
                try:
                    raise KeyError('No such message: '+msg_id)
                except:
                    content = error.wrap_exception()
                break
        self.session.send(self.query, "result_reply", content=content,
                                            parent=msg, ident=client_id,
                                            buffers=buffers)
def get_results(self, client_id, msg):
        content = msg['content']
        msg_ids = sorted(set(content['msg_ids']))
        statusonly = content.get('status_only', False)
        pending = []
        completed = []
        content = dict(status='ok')
        content['pending'] = pending
        content['completed'] = completed
        buffers = []
        if not statusonly:
            try:
                matches = self.db.find_records(dict(msg_id={'$in':msg_ids}))
                # turn match list into dict, for faster lookup
                records = {}
                for rec in matches:
                    records[rec['msg_id']] = rec
            except Exception:
                content = error.wrap_exception()
                self.session.send(self.query, "result_reply", content=content,
                                                    parent=msg, ident=client_id)
                return
        else:
            records = {}
        for msg_id in msg_ids:
            if msg_id in self.pending:
                pending.append(msg_id)
            elif msg_id in self.all_completed:
                completed.append(msg_id)
                if not statusonly:
                    c,bufs = self._extract_record(records[msg_id])
                    content[msg_id] = c
                    buffers.extend(bufs)
            elif msg_id in records:
                if rec['completed']:
                    completed.append(msg_id)
                    c,bufs = self._extract_record(records[msg_id])
                    content[msg_id] = c
                    buffers.extend(bufs)
                else:
                    pending.append(msg_id)
            else:
                try:
                    raise KeyError('No such message: '+msg_id)
                except:
                    content = error.wrap_exception()
                break
        self.session.send(self.query, "result_reply", content=content,
                                            parent=msg, ident=client_id,
                                            buffers=buffers)
def get_results ( self , client_id , msg ) : content = msg [ 'content' ] msg_ids = sorted ( set ( content [ 'msg_ids' ] ) ) statusonly = content . get ( 'status_only' , False ) pending = [ ] completed = [ ] content = dict ( status = 'ok' ) content [ 'pending' ] = pending content [ 'completed' ] = completed buffers = [ ] if not statusonly : try : matches = self . db . find_records ( dict ( msg_id = { '$in' : msg_ids } ) ) # turn match list into dict, for faster lookup records = { } for rec in matches : records [ rec [ 'msg_id' ] ] = rec except Exception : content = error . wrap_exception ( ) self . session . send ( self . query , "result_reply" , content = content , parent = msg , ident = client_id ) return else : records = { } for msg_id in msg_ids : if msg_id in self . pending : pending . append ( msg_id ) elif msg_id in self . all_completed : completed . append ( msg_id ) if not statusonly : c , bufs = self . _extract_record ( records [ msg_id ] ) content [ msg_id ] = c buffers . extend ( bufs ) elif msg_id in records : if rec [ 'completed' ] : completed . append ( msg_id ) c , bufs = self . _extract_record ( records [ msg_id ] ) content [ msg_id ] = c buffers . extend ( bufs ) else : pending . append ( msg_id ) else : try : raise KeyError ( 'No such message: ' + msg_id ) except : content = error . wrap_exception ( ) break self . session . send ( self . query , "result_reply" , content = content , parent = msg , ident = client_id , buffers = buffers )
Get the result of 1 or more messages.
Get the result of 1 or more messages .