How to use the greenlet.error 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 python-greenlet / greenlet / tests / test_extension_interface.py View on Github external
def test_raise_greenlet_error(self):
        self.assertRaises(
            greenlet.error, _test_extension.test_raise_greenlet_error)
github ilastik / lazyflow / lazyflow / request / request.py View on Github external
def _suspend(self):
        """
        Suspend this request so another one can be woken up by the worker.
        """
        # Switch back to the worker that we're currently running in.
        try:
            self.greenlet.parent.switch()
        except greenlet.error:
            logger.critical( "Current thread ({}) could not suspend task: {}.  (parent greenlet={})"
                             .format( threading.current_thread().name, self, self.greenlet.parent ) )
            raise
github ilastik / ilastik / lazyflow / request / request.py View on Github external
def _switch_to(self):
        """
        Switch to this request's greenlet
        """
        try:
            self.greenlet.switch()
        except greenlet.error:
            # This is a serious error.
            # If we are handling an exception here, it means there's a bug in the request framework,
            #  not the client's code.
            msg = "Current thread ({}) could not start/resume task: {}"\
                  .format( threading.current_thread().name, self )
            log_exception( logger, msg, level=logging.CRITICAL )
            
            # We still run the post-execute code, so that all requests waiting on this 
            #  one will be notified of the error and produce their own tracebacks.
            # Hopefully that will help us reproduce/debug the issue.
            self.exception = Request.InternalError( "A serious error was detected while waiting for another request.  "
                                                    "Check the log for other exceptions." )
            self.exception_info = ( type(self.exception), 
                                    self.exception, 
                                    sys.exc_info()[2] ) 
            self._post_execute()