environment/lib/python2.7/site-packages/IPython/parallel/client/client.py
def _connect(self, sshserver, ssh_kwargs, timeout):
        """setup all our socket connections to the cluster. This is called from
        __init__."""

        # Maybe allow reconnecting?
        if self._connected:
            return
        self._connected=True

        def connect_socket(s, url):
            url = util.disambiguate_url(url, self._config['location'])
            if self._ssh:
                return tunnel.tunnel_connection(s, url, sshserver, **ssh_kwargs)
            else:
                return s.connect(url)

        self.session.send(self._query_socket, 'connection_request')
        # use Poller because zmq.select has wrong units in pyzmq 2.1.7
        poller = zmq.Poller()
        poller.register(self._query_socket, zmq.POLLIN)
        # poll expects milliseconds, timeout is seconds
        evts = poller.poll(timeout*1000)
        if not evts:
            raise error.TimeoutError("Hub connection request timed out")
        idents,msg = self.session.recv(self._query_socket,mode=0)
        if self.debug:
            pprint(msg)
        msg = Message(msg)
        content = msg.content
        self._config['registration'] = dict(content)
        if content.status == 'ok':
            ident = self.session.bsession
            if content.mux:
                self._mux_socket = self._context.socket(zmq.DEALER)
                self._mux_socket.setsockopt(zmq.IDENTITY, ident)
                connect_socket(self._mux_socket, content.mux)
            if content.task:
                self._task_scheme, task_addr = content.task
                self._task_socket = self._context.socket(zmq.DEALER)
                self._task_socket.setsockopt(zmq.IDENTITY, ident)
                connect_socket(self._task_socket, task_addr)
            if content.notification:
                self._notification_socket = self._context.socket(zmq.SUB)
                connect_socket(self._notification_socket, content.notification)
                self._notification_socket.setsockopt(zmq.SUBSCRIBE, b'')
            # if content.query:
            #     self._query_socket = self._context.socket(zmq.DEALER)
            #     self._query_socket.setsockopt(zmq.IDENTITY, self.session.bsession)
            #     connect_socket(self._query_socket, content.query)
            if content.control:
                self._control_socket = self._context.socket(zmq.DEALER)
                self._control_socket.setsockopt(zmq.IDENTITY, ident)
                connect_socket(self._control_socket, content.control)
            if content.iopub:
                self._iopub_socket = self._context.socket(zmq.SUB)
                self._iopub_socket.setsockopt(zmq.SUBSCRIBE, b'')
                self._iopub_socket.setsockopt(zmq.IDENTITY, ident)
                connect_socket(self._iopub_socket, content.iopub)
            self._update_engines(dict(content.engines))
        else:
            self._connected = False
            raise Exception("Failed to connect!")
def _connect(self, sshserver, ssh_kwargs, timeout):
        """setup all our socket connections to the cluster. This is called from
        __init__."""

        # Maybe allow reconnecting?
        if self._connected:
            return
        self._connected=True

        def connect_socket(s, url):
            url = util.disambiguate_url(url, self._config['location'])
            if self._ssh:
                return tunnel.tunnel_connection(s, url, sshserver, **ssh_kwargs)
            else:
                return s.connect(url)

        self.session.send(self._query_socket, 'connection_request')
        # use Poller because zmq.select has wrong units in pyzmq 2.1.7
        poller = zmq.Poller()
        poller.register(self._query_socket, zmq.POLLIN)
        # poll expects milliseconds, timeout is seconds
        evts = poller.poll(timeout*1000)
        if not evts:
            raise error.TimeoutError("Hub connection request timed out")
        idents,msg = self.session.recv(self._query_socket,mode=0)
        if self.debug:
            pprint(msg)
        msg = Message(msg)
        content = msg.content
        self._config['registration'] = dict(content)
        if content.status == 'ok':
            ident = self.session.bsession
            if content.mux:
                self._mux_socket = self._context.socket(zmq.DEALER)
                self._mux_socket.setsockopt(zmq.IDENTITY, ident)
                connect_socket(self._mux_socket, content.mux)
            if content.task:
                self._task_scheme, task_addr = content.task
                self._task_socket = self._context.socket(zmq.DEALER)
                self._task_socket.setsockopt(zmq.IDENTITY, ident)
                connect_socket(self._task_socket, task_addr)
            if content.notification:
                self._notification_socket = self._context.socket(zmq.SUB)
                connect_socket(self._notification_socket, content.notification)
                self._notification_socket.setsockopt(zmq.SUBSCRIBE, b'')
            # if content.query:
            #     self._query_socket = self._context.socket(zmq.DEALER)
            #     self._query_socket.setsockopt(zmq.IDENTITY, self.session.bsession)
            #     connect_socket(self._query_socket, content.query)
            if content.control:
                self._control_socket = self._context.socket(zmq.DEALER)
                self._control_socket.setsockopt(zmq.IDENTITY, ident)
                connect_socket(self._control_socket, content.control)
            if content.iopub:
                self._iopub_socket = self._context.socket(zmq.SUB)
                self._iopub_socket.setsockopt(zmq.SUBSCRIBE, b'')
                self._iopub_socket.setsockopt(zmq.IDENTITY, ident)
                connect_socket(self._iopub_socket, content.iopub)
            self._update_engines(dict(content.engines))
        else:
            self._connected = False
            raise Exception("Failed to connect!")
def _connect ( self , sshserver , ssh_kwargs , timeout ) : # Maybe allow reconnecting? if self . _connected : return self . _connected = True def connect_socket ( s , url ) : url = util . disambiguate_url ( url , self . _config [ 'location' ] ) if self . _ssh : return tunnel . tunnel_connection ( s , url , sshserver , * * ssh_kwargs ) else : return s . connect ( url ) self . session . send ( self . _query_socket , 'connection_request' ) # use Poller because zmq.select has wrong units in pyzmq 2.1.7 poller = zmq . Poller ( ) poller . register ( self . _query_socket , zmq . POLLIN ) # poll expects milliseconds, timeout is seconds evts = poller . poll ( timeout * 1000 ) if not evts : raise error . TimeoutError ( "Hub connection request timed out" ) idents , msg = self . session . recv ( self . _query_socket , mode = 0 ) if self . debug : pprint ( msg ) msg = Message ( msg ) content = msg . content self . _config [ 'registration' ] = dict ( content ) if content . status == 'ok' : ident = self . session . bsession if content . mux : self . _mux_socket = self . _context . socket ( zmq . DEALER ) self . _mux_socket . setsockopt ( zmq . IDENTITY , ident ) connect_socket ( self . _mux_socket , content . mux ) if content . task : self . _task_scheme , task_addr = content . task self . _task_socket = self . _context . socket ( zmq . DEALER ) self . _task_socket . setsockopt ( zmq . IDENTITY , ident ) connect_socket ( self . _task_socket , task_addr ) if content . notification : self . _notification_socket = self . _context . socket ( zmq . SUB ) connect_socket ( self . _notification_socket , content . notification ) self . _notification_socket . setsockopt ( zmq . SUBSCRIBE , b'' ) # if content.query: #     self._query_socket = self._context.socket(zmq.DEALER) #     self._query_socket.setsockopt(zmq.IDENTITY, self.session.bsession) #     connect_socket(self._query_socket, content.query) if content . control : self . _control_socket = self . _context . socket ( zmq . DEALER ) self . _control_socket . setsockopt ( zmq . IDENTITY , ident ) connect_socket ( self . _control_socket , content . control ) if content . iopub : self . _iopub_socket = self . _context . socket ( zmq . SUB ) self . _iopub_socket . setsockopt ( zmq . SUBSCRIBE , b'' ) self . _iopub_socket . setsockopt ( zmq . IDENTITY , ident ) connect_socket ( self . _iopub_socket , content . iopub ) self . _update_engines ( dict ( content . engines ) ) else : self . _connected = False raise Exception ( "Failed to connect!" )
setup all our socket connections to the cluster. This is called from
        __init__.
setup all our socket connections to the cluster . This is called from __init__ .