How to use the greenlet.GreenletExit function in greenlet

To help you get started, we’ve selected a few greenlet 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 crowbar / crowbar-openstack / chef / cookbooks / nova / files / default / san.py View on Github external
    @functools.wraps(f)
    def __inner(self, *args, **kwargs):
        timeout = kwargs.pop('timeout', None)
        gt = eventlet.spawn(f, self, *args, **kwargs)
        if timeout is None:
            return gt.wait()
        else:
            kill_thread = eventlet.spawn_after(timeout, gt.kill)
            try:
                res = gt.wait()
            except greenlet.GreenletExit:
                raise Timeout()
            else:
                kill_thread.cancel()
                return res
github openstack / barbican / barbican / openstack / common / rpc / impl_qpid.py View on Github external
def cancel_consumer_thread(self):
        """Cancel a consumer thread."""
        if self.consumer_thread is not None:
            self.consumer_thread.kill()
            try:
                self.consumer_thread.wait()
            except greenlet.GreenletExit:
                pass
            self.consumer_thread = None
github spcs / synaps / synaps / wsgi.py View on Github external
def wait(self):
        """Block, until the server has stopped.

        Waits on the server's eventlet to finish, then returns.

        :returns: None

        """
        try:
            self._server.wait()
        except greenlet.GreenletExit:
            LOG.info(_("WSGI server has stopped."))
github veegee / guv / guv / greenthread.py View on Github external
def just_raise(*a, **kw):
            if throw_args:
                reraise(throw_args[0], throw_args[1], throw_args[2])
            else:
                raise greenlet.GreenletExit()
github openstack / nova / nova / rpc / impl_carrot.py View on Github external
def cancel_consumer_thread(self):
        """Cancel a consumer thread"""
        if self._rpc_consumer_thread is not None:
            self._rpc_consumer_thread.kill()
            try:
                self._rpc_consumer_thread.wait()
            except greenlet.GreenletExit:
                pass
            self._rpc_consumer_thread = None
github openstack / murano / murano / engine / system / agent_listener.py View on Github external
def stop(self):
        if CONF.engine.disable_murano_agent:
            # Noop
            LOG.debug("murano-agent is disabled by the server")
            return

        if self._receive_thread is not None:
            self._receive_thread.kill()
            try:
                self._receive_thread.wait()
            except greenlet.GreenletExit:
                pass
            finally:
                self._receive_thread = None
github tuskar / tuskar / tuskar / openstack / common / rpc / impl_zmq.py View on Github external
def _get_response(self, ctx, proxy, topic, data):
        """Process a curried message and cast the result to topic."""
        LOG.debug(_("Running func with context: %s"), ctx.to_dict())
        data.setdefault('version', None)
        data.setdefault('args', {})

        try:
            result = proxy.dispatch(
                ctx, data['version'], data['method'],
                data.get('namespace'), **data['args'])
            return ConsumerBase.normalize_reply(result, ctx.replies)
        except greenlet.GreenletExit:
            # ignore these since they are just from shutdowns
            pass
        except rpc_common.ClientException as e:
            LOG.debug(_("Expected exception during message handling (%s)") %
                      e._exc_info[1])
            return {'exc':
                    rpc_common.serialize_remote_exception(e._exc_info,
                                                          log_failure=False)}
        except Exception:
            LOG.error(_("Exception during message handling"))
            return {'exc':
                    rpc_common.serialize_remote_exception(sys.exc_info())}
github openstack / ceilometer / ceilometer / openstack / common / rpc / impl_qpid.py View on Github external
def _consumer_thread():
            try:
                self.consume()
            except greenlet.GreenletExit:
                return
        if self.consumer_thread is None:
github gevent / gevent / gevent / hub.py View on Github external
def kill(greenlet, exception=GreenletExit):
    """Kill greenlet asynchronously. The current greenlet is not unscheduled.

    Note, that :meth:`gevent.Greenlet.kill` method does the same and more. However,
    MAIN greenlet - the one that exists initially - does not have ``kill()`` method
    so you have to use this function.
    """
    if not greenlet.dead:
        get_hub().loop.run_callback(greenlet.throw, exception)
github openstack / blazar / climate / openstack / common / rpc / impl_kombu.py View on Github external
def _consumer_thread():
            try:
                self.consume()
            except greenlet.GreenletExit:
                return
        if self.consumer_thread is None: