def set_eventlet_hub(): try: eventlet.hubs.use_hub(cfg.CONF.eventlet_hub) except Exception: msg = _("eventlet '%s' hub is not available on this platform") raise exception.WorkerCreationFailure(reason=msg % cfg.CONF.eventlet_hub)
def test_main_with_worker_creation_failure(self): with mock.patch.object(glance.common.config, 'parse_args') as mock_config: with mock.patch('sys.exit') as mock_exit: exx = exc.WorkerCreationFailure() mock_config.side_effect = exx glance.cmd.api.main() mock_exit.assert_called_once_with(2)
def set_eventlet_hub(): try: eventlet.hubs.use_hub('poll') except Exception: try: eventlet.hubs.use_hub('selects') except Exception: msg = _("eventlet 'poll' nor 'selects' hubs are available " "on this platform") raise exception.WorkerCreationFailure(reason=msg)
def run_server(self): """Run a WSGI server.""" eventlet.wsgi.HttpProtocol.default_request_version = "HTTP/1.0" try: eventlet.hubs.use_hub('poll') except Exception: msg = _("eventlet 'poll' hub is not available on this platform") raise exception.WorkerCreationFailure(reason=msg) eventlet.patcher.monkey_patch(all=False, socket=True) self.pool = eventlet.GreenPool(size=self.threads) try: eventlet.wsgi.server(self.sock, self.app_func(), log=WritableLogger(self.logger), custom_pool=self.pool) except socket.error, err: if err[0] != errno.EINVAL: raise
def run_server(self): """Run a WSGI server.""" if cfg.CONF.pydev_worker_debug_host: utils.setup_remote_pydev_debug(cfg.CONF.pydev_worker_debug_host, cfg.CONF.pydev_worker_debug_port) eventlet.wsgi.HttpProtocol.default_request_version = "HTTP/1.0" try: eventlet.hubs.use_hub('poll') except Exception: msg = _("eventlet 'poll' hub is not available on this platform") raise exception.WorkerCreationFailure(reason=msg) self.pool = self.create_pool() try: eventlet.wsgi.server(self.sock, self.application, log=WritableLogger(self.logger), custom_pool=self.pool) except socket.error, err: if err[0] != errno.EINVAL: raise
def test_worker_creation_failure(self, mock_prefetcher): failure = exc.WorkerCreationFailure(reason='test') self.mock_object(glance.common.wsgi.Server, 'start', self._raise(failure)) exit = self.assertRaises(SystemExit, glance.cmd.api.main) self.assertEqual(2, exit.code)
def test_worker_creation_failure(self): failure = exc.WorkerCreationFailure(reason='test') self.stubs.Set(glance.common.wsgi.Server, 'start', self._raise(failure)) exit = self.assertRaises(SystemExit, glance.cmd.api.main) self.assertEqual(exit.code, 2)