environment/lib/python2.7/site-packages/IPython/parallel/client/client.py
def send_apply_request(self, socket, f, args=None, kwargs=None, subheader=None, track=False,
                            ident=None):
        """construct and send an apply message via a socket.

        This is the principal method with which all engine execution is performed by views.
        """

        if self._closed:
            raise RuntimeError("Client cannot be used after its sockets have been closed")
        
        # defaults:
        args = args if args is not None else []
        kwargs = kwargs if kwargs is not None else {}
        subheader = subheader if subheader is not None else {}

        # validate arguments
        if not callable(f) and not isinstance(f, Reference):
            raise TypeError("f must be callable, not %s"%type(f))
        if not isinstance(args, (tuple, list)):
            raise TypeError("args must be tuple or list, not %s"%type(args))
        if not isinstance(kwargs, dict):
            raise TypeError("kwargs must be dict, not %s"%type(kwargs))
        if not isinstance(subheader, dict):
            raise TypeError("subheader must be dict, not %s"%type(subheader))

        bufs = util.pack_apply_message(f,args,kwargs)

        msg = self.session.send(socket, "apply_request", buffers=bufs, ident=ident,
                            subheader=subheader, track=track)

        msg_id = msg['header']['msg_id']
        self.outstanding.add(msg_id)
        if ident:
            # possibly routed to a specific engine
            if isinstance(ident, list):
                ident = ident[-1]
            if ident in self._engines.values():
                # save for later, in case of engine death
                self._outstanding_dict[ident].add(msg_id)
        self.history.append(msg_id)
        self.metadata[msg_id]['submitted'] = datetime.now()

        return msg
def send_apply_request(self, socket, f, args=None, kwargs=None, subheader=None, track=False,
                            ident=None):
        if self._closed:
            raise RuntimeError("Client cannot be used after its sockets have been closed")
        
        # defaults:
        args = args if args is not None else []
        kwargs = kwargs if kwargs is not None else {}
        subheader = subheader if subheader is not None else {}

        # validate arguments
        if not callable(f) and not isinstance(f, Reference):
            raise TypeError("f must be callable, not %s"%type(f))
        if not isinstance(args, (tuple, list)):
            raise TypeError("args must be tuple or list, not %s"%type(args))
        if not isinstance(kwargs, dict):
            raise TypeError("kwargs must be dict, not %s"%type(kwargs))
        if not isinstance(subheader, dict):
            raise TypeError("subheader must be dict, not %s"%type(subheader))

        bufs = util.pack_apply_message(f,args,kwargs)

        msg = self.session.send(socket, "apply_request", buffers=bufs, ident=ident,
                            subheader=subheader, track=track)

        msg_id = msg['header']['msg_id']
        self.outstanding.add(msg_id)
        if ident:
            # possibly routed to a specific engine
            if isinstance(ident, list):
                ident = ident[-1]
            if ident in self._engines.values():
                # save for later, in case of engine death
                self._outstanding_dict[ident].add(msg_id)
        self.history.append(msg_id)
        self.metadata[msg_id]['submitted'] = datetime.now()

        return msg
def send_apply_request ( self , socket , f , args = None , kwargs = None , subheader = None , track = False , ident = None ) : if self . _closed : raise RuntimeError ( "Client cannot be used after its sockets have been closed" ) # defaults: args = args if args is not None else [ ] kwargs = kwargs if kwargs is not None else { } subheader = subheader if subheader is not None else { } # validate arguments if not callable ( f ) and not isinstance ( f , Reference ) : raise TypeError ( "f must be callable, not %s" % type ( f ) ) if not isinstance ( args , ( tuple , list ) ) : raise TypeError ( "args must be tuple or list, not %s" % type ( args ) ) if not isinstance ( kwargs , dict ) : raise TypeError ( "kwargs must be dict, not %s" % type ( kwargs ) ) if not isinstance ( subheader , dict ) : raise TypeError ( "subheader must be dict, not %s" % type ( subheader ) ) bufs = util . pack_apply_message ( f , args , kwargs ) msg = self . session . send ( socket , "apply_request" , buffers = bufs , ident = ident , subheader = subheader , track = track ) msg_id = msg [ 'header' ] [ 'msg_id' ] self . outstanding . add ( msg_id ) if ident : # possibly routed to a specific engine if isinstance ( ident , list ) : ident = ident [ - 1 ] if ident in self . _engines . values ( ) : # save for later, in case of engine death self . _outstanding_dict [ ident ] . add ( msg_id ) self . history . append ( msg_id ) self . metadata [ msg_id ] [ 'submitted' ] = datetime . now ( ) return msg
construct and send an apply message via a socket.

        This is the principal method with which all engine execution is performed by views.
construct and send an apply message via a socket .