Skip to content

Commit

Permalink
Merge "Yield to another greenthread when some time-consuming task fin…
Browse files Browse the repository at this point in the history
…ished."
  • Loading branch information
Jenkins authored and openstack-gerrit committed Sep 5, 2012
2 parents 84c62b3 + be72921 commit 6c6e6a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions nova/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
"""

import eventlet

from nova.db import base
from nova import flags
from nova.openstack.common import log as logging
Expand Down Expand Up @@ -171,6 +173,9 @@ def periodic_tasks(self, context, raise_on_error=False):

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
Expand Down
5 changes: 4 additions & 1 deletion nova/virt/libvirt/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1996,6 +1996,8 @@ def get_vcpu_used(self):
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):
Expand Down Expand Up @@ -2690,7 +2692,8 @@ def get_disk_available_least(self):
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)
Expand Down

0 comments on commit 6c6e6a8

Please sign in to comment.