Example #1
0
def error_handler(self: Any, _context: Any, etype: Any, value: Any,
                  _tb: Any) -> None:
    if issubclass(etype, Hub.NOT_ERROR):
        return
    if issubclass(etype, KeyboardInterrupt):
        log.info("Service termination requested by user.")
        sys.exit()

    log.critical("Unhandled exception. Terminating the program..."
                 "Please report this issue at "
                 "https://github.com/raiden-network/raiden-services/issues")
    # This will properly raise the exception and stop the process
    Hub.handle_system_error(self, etype, value)
Example #2
0
    def handle_error(self, context, type, value, tb):
        type, value, tb = self._normalize_exception(type, value, tb)

        if issubclass(type, self.EXPECTED_TEST_ERROR):
            # Don't print these to cut down on the noise in the test logs
            return
        return Hub.handle_error(self, context, type, value, tb)
Example #3
0
    def handle_error(self, context, type, value, tb):
        type, value, tb = self._normalize_exception(type, value, tb)
        # If we check that the ``type`` is a subclass of ``EXPECTED_TEST_ERROR``,
        # and return, we completely change the semantics: We avoid raising
        # this error in the main greenlet, which cuts out several switches.
        # Overall, not good.

        if self.IGNORE_EXPECTED_TEST_ERROR and issubclass(
                type, self.EXPECTED_TEST_ERROR):
            # Don't pass these up; avoid switches
            return
        return Hub.handle_error(self, context, type, value, tb)
    def _check_backend(self, backend):
        hub = Hub(backend, default=False)
        try:
            self.assertEqual(hub.loop.backend, backend)

            gevent.sleep(0.001)
            fileno = hub.loop.fileno()
            if fileno is None:
                raise unittest.SkipTest("backend %s lacks fileno" %
                                        (backend, ))

            os.close(fileno)
            if backend not in ('kqueue', 'epoll'):
                # That's actually all the libev backends that use a file descriptor,
                # right?
                with self.assertRaisesRegex(SystemError, "(libev)"):
                    gevent.sleep(0.001)

            hub.destroy()
            self.assertIn('destroyed', repr(hub))
        finally:
            if hub.loop is not None:
                hub.destroy()
    def _check_backend(self, backend):
        hub = Hub(backend, default=False)

        try:
            self.assertEqual(hub.loop.backend, backend)

            gevent.sleep(0.001)
            fileno = hub.loop.fileno()
            if fileno is None:
                return  # nothing to close, test implicitly passes.

            os.close(fileno)

            if backend in self.BACKENDS_THAT_SUCCEED_WHEN_FD_CLOSED:
                gevent.sleep(0.001)
            else:
                with self.assertRaisesRegex(SystemError, "(libev)"):
                    gevent.sleep(0.001)

            hub.destroy()
            self.assertIn('destroyed', repr(hub))
        finally:
            if hub.loop is not None:
                hub.destroy()
 def test(self):
     with self.assertRaisesRegex(SystemError, 'ev_loop_new'):
         Hub(backend, default=False)
Example #7
0
 def print_exception(self, context, t, v, tb):
     t, v, tb = self._normalize_exception(t, v, tb)
     if issubclass(t, self.EXPECTED_TEST_ERROR):
         # see handle_error
         return
     return Hub.print_exception(self, context, t, v, tb)
Example #8
0
File: hub.py Project: gevent/gevent
 def handle_error(self, context, type, value, tb):
     if issubclass(type, self.EXPECTED_TEST_ERROR):
         # Don't print these to cut down on the noise in the test logs
         return
     return Hub.handle_error(self, context, type, value, tb)