diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py index f448c8140f31..f49c76326ac5 100644 --- a/nova/scheduler/host_manager.py +++ b/nova/scheduler/host_manager.py @@ -19,7 +19,6 @@ Manage hosts in the current zone. import collections import functools -import time import iso8601 from oslo_log import log as logging @@ -465,8 +464,7 @@ class HostManager(object): "updated": False} inst_dict = self._instance_info[host] inst_dict["instances"][instance.uuid] = instance - # Call sleep() to cooperatively yield - time.sleep(0) + utils.cooperative_yield() LOG.debug("END:_async_init_instance_info") # Run this async so that we don't block the scheduler start-up diff --git a/nova/tests/unit/virt/disk/mount/test_nbd.py b/nova/tests/unit/virt/disk/mount/test_nbd.py index cc0e04337ecf..707cff25017f 100644 --- a/nova/tests/unit/virt/disk/mount/test_nbd.py +++ b/nova/tests/unit/virt/disk/mount/test_nbd.py @@ -16,13 +16,13 @@ import os import tempfile -import time from unittest import mock import eventlet import fixtures from nova import test +from nova import utils from nova.virt.disk.mount import nbd from nova.virt.image import model as imgmodel @@ -304,7 +304,7 @@ class NbdTestCase(test.NoDBTestCase): # Ensure that context switch happens before the device is marked # as used. This will cause a failure without nbd-allocation-lock # in place. - time.sleep(0.1) + utils.cooperative_yield() # We always choose the top device in find_unused - remove it now. free_devices.pop() diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 4375dc754b60..f196ebebc4de 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -11537,7 +11537,7 @@ class LibvirtDriver(driver.ComputeDriver): future.add_done_callback(thread_finished) # Let eventlet schedule the new thread right away - time.sleep(0) + utils.cooperative_yield() try: LOG.debug("Starting monitoring of live migration",