How to use the ipyparallel.error.TimeoutError function in ipyparallel

To help you get started, we’ve selected a few ipyparallel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipython / ipyparallel / ipyparallel / client / asyncresult.py View on Github external
If `timeout` is not ``None`` and the result does not arrive within
        `timeout` seconds then ``TimeoutError`` is raised. If the
        remote call raised an exception then that exception will be reraised
        by get() inside a `RemoteError`.
        """
        if not self.ready():
            self.wait(timeout)

        if self._ready:
            if self._success:
                return self.result()
            else:
                raise self.exception()
        else:
            raise error.TimeoutError("Result not ready.")
github ipython / ipyparallel / ipyparallel / client / asyncresult.py View on Github external
timeout = None
            # wait for Future to indicate send having been called,
            # which means MessageTracker is ready.
            tic = time.time()
            if not self._sent_event.wait(timeout):
                raise error.TimeoutError("Still waiting to be sent")
                return False
            if timeout:
                timeout = max(0, timeout - (time.time() - tic))
        try:
            if timeout is None:
                # MessageTracker doesn't like timeout=None
                timeout = -1
            return self._tracker.wait(timeout)
        except zmq.NotDone:
            raise error.TimeoutError("Still waiting to be sent")
github ipython / ipyparallel / ipyparallel / client / client.py View on Github external
def connect_socket(s, url):
            if self._ssh:
                from zmq.ssh import tunnel
                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)
        content = msg['content']
        # self._config['registration'] = dict(content)
        cfg = self._config
        if content['status'] == 'ok':
            self._mux_socket = self._context.socket(zmq.DEALER)
            connect_socket(self._mux_socket, cfg['mux'])

            self._task_socket = self._context.socket(zmq.DEALER)
            connect_socket(self._task_socket, cfg['task'])

            self._notification_socket = self._context.socket(zmq.SUB)
            self._notification_socket.setsockopt(zmq.SUBSCRIBE, b'')
            connect_socket(self._notification_socket, cfg['notification'])
github nipy / nipype / nipype / pipeline / plugins / ipython.py View on Github external
"""Executes a pre-defined pipeline is distributed approaches
        based on IPython's ipyparallel processing interface
        """
        # retrieve clients again
        try:
            name = 'ipyparallel'
            __import__(name)
            self.iparallel = sys.modules[name]
        except ImportError as e:
            raise_from(
                ImportError("ipyparallel not found. Parallel execution "
                            "will be unavailable"), e)
        try:
            self.taskclient = self.iparallel.Client(**self.client_args)
        except Exception as e:
            if isinstance(e, TimeoutError):
                raise_from(Exception("No IPython clients found."), e)
            if isinstance(e, IOError):
                raise_from(
                    Exception("ipcluster/ipcontroller has not been started"),
                    e)
            if isinstance(e, ValueError):
                raise_from(Exception("Ipython kernel not installed"), e)
            else:
                raise e
        return super(IPythonPlugin, self).run(
            graph, config, updatehash=updatehash)
github ipython / ipyparallel / ipyparallel / client / asyncresult.py View on Github external
def _check_ready(self):
        if not self.ready():
            raise error.TimeoutError("Result not ready.")
github roryk / ipython-cluster-helper / cluster_helper / cluster.py View on Github external
def _nengines_up(url_file):
    "return the number of engines up"
    client = None
    try:
        client = Client(url_file, timeout=60)
        up = len(client.ids)
        client.close()
    # the controller isn't up yet
    except iperror.TimeoutError:
        return 0
    # the JSON file is not available to parse
    except IOError:
        return 0
    else:
        return up