summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-09-05 15:05:05 +0000
committerGerrit Code Review <review@openstack.org>2012-09-05 15:05:05 +0000
commit6c6e6a8f48471c2feb6b120a0b14d313a3ee25bb (patch)
tree881bc1a910203c2e42469624dca8920248aceb55 /nova
parent84c62b35ff349ff0301eed36f765031d400e6c24 (diff)
parentbe72921c6f38b8b71ffc474ceae58e67241dac22 (diff)
Merge "Yield to another greenthread when some time-consuming task finished."
Diffstat (limited to 'nova')
-rw-r--r--nova/manager.py5
-rw-r--r--nova/virt/libvirt/driver.py5
2 files changed, 9 insertions, 1 deletions
diff --git a/nova/manager.py b/nova/manager.py
index c6711aadb..275d98b61 100644
--- a/nova/manager.py
+++ b/nova/manager.py
@@ -53,6 +53,8 @@ This module provides Manager, a base class for managers.
"""
+import eventlet
+
from nova.db import base
from nova import flags
from nova.openstack.common import log as logging
@@ -171,6 +173,9 @@ class Manager(base.Base):
try:
task(self, context)
+ # NOTE(tiantian): After finished a task, allow manager to
+ # do other work (report_state, processing AMPQ request etc.)
+ eventlet.sleep(0)
except Exception as e:
if raise_on_error:
raise
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index c9326e71b..203789f6f 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -1996,6 +1996,8 @@ class LibvirtDriver(driver.ComputeDriver):
total += 1
else:
total += len(vcpus[1])
+ # NOTE(gtt116): give change to do other task.
+ greenthread.sleep(0)
return total
def get_memory_mb_used(self):
@@ -2690,7 +2692,8 @@ class LibvirtDriver(driver.ComputeDriver):
except exception.InstanceNotFound:
# Instance was deleted during the check so ignore it
pass
-
+ # NOTE(gtt116): give change to do other task.
+ greenthread.sleep(0)
# Disk available least size
available_least_size = dk_sz_gb * (1024 ** 3) - instances_sz
return (available_least_size / 1024 / 1024 / 1024)