Merge "Do not fork compute workers in native threading mode"
This commit is contained in:
+2
-1
@@ -61,5 +61,6 @@ def main():
|
||||
objects.Service.enable_min_version_cache()
|
||||
server = service.Service.create(binary='nova-compute',
|
||||
topic=compute_rpcapi.RPC_TOPIC)
|
||||
service.serve(server)
|
||||
# Compute service should never fork worker processes
|
||||
service.serve(server, workers=1, no_fork=True)
|
||||
service.wait()
|
||||
|
||||
+2
-2
@@ -322,13 +322,13 @@ class Service(service.Service):
|
||||
_launcher = None
|
||||
|
||||
|
||||
def serve(server, workers=None):
|
||||
def serve(server, workers=None, no_fork=False):
|
||||
global _launcher
|
||||
if _launcher:
|
||||
raise RuntimeError(_('serve() can only be called once'))
|
||||
|
||||
_launcher = service.launch(CONF, server, workers=workers,
|
||||
restart_method='mutate')
|
||||
restart_method='mutate', no_fork=no_fork)
|
||||
|
||||
|
||||
def wait():
|
||||
|
||||
@@ -324,7 +324,8 @@ class TestLauncher(test.NoDBTestCase):
|
||||
mock_launch.assert_called_once_with(mock.ANY,
|
||||
mock.sentinel.service,
|
||||
workers=None,
|
||||
restart_method='mutate')
|
||||
restart_method='mutate',
|
||||
no_fork=False)
|
||||
|
||||
@mock.patch.object(_service, 'launch')
|
||||
def test_launch_app_with_workers(self, mock_launch):
|
||||
@@ -333,7 +334,19 @@ class TestLauncher(test.NoDBTestCase):
|
||||
mock_launch.assert_called_once_with(mock.ANY,
|
||||
mock.sentinel.service,
|
||||
workers=mock.sentinel.workers,
|
||||
restart_method='mutate')
|
||||
restart_method='mutate',
|
||||
no_fork=False)
|
||||
|
||||
@mock.patch.object(_service, 'launch')
|
||||
def test_launch_app_with_workers_no_fork(self, mock_launch):
|
||||
service._launcher = None
|
||||
service.serve(
|
||||
mock.sentinel.service, workers=mock.sentinel.workers, no_fork=True)
|
||||
mock_launch.assert_called_once_with(mock.ANY,
|
||||
mock.sentinel.service,
|
||||
workers=mock.sentinel.workers,
|
||||
restart_method='mutate',
|
||||
no_fork=True)
|
||||
|
||||
@mock.patch.object(_service, 'launch')
|
||||
def test_launch_app_more_than_once_raises(self, mock_launch):
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ oslo.messaging>=14.1.0 # Apache-2.0
|
||||
oslo.policy>=4.5.0 # Apache-2.0
|
||||
oslo.privsep>=2.6.2 # Apache-2.0
|
||||
oslo.i18n>=5.1.0 # Apache-2.0
|
||||
oslo.service[threading]>=4.2.0 # Apache-2.0
|
||||
oslo.service[threading]>=4.4.1 # Apache-2.0
|
||||
rfc3986>=1.2.0 # Apache-2.0
|
||||
oslo.middleware>=3.31.0 # Apache-2.0
|
||||
psutil>=3.2.2 # BSD
|
||||
|
||||
Reference in New Issue
Block a user