Rework virt.xenapi's concurrency model. There were many places where we were

inadvertently blocking the reactor thread.  The reworking puts all calls to
XenAPI on background threads, so that they won't block the reactor thread.

Long-lived operations (VM start, reboot, etc) are invoked asynchronously
at the XenAPI level (Async.VM.start, etc).  These return a XenAPI task.  We
relinquish the background thread at this point, so as not to hold threads in
the pool for too long, and use reactor.callLater to poll the task.

This combination of techniques means that we don't block the reactor thread at
all, and at the same time we don't hold lots of threads waiting for
long-running operations.

There is a FIXME in here: get_info does not conform to these new rules.
Changes are required in compute.service before we can make get_info
non-blocking.
This commit is contained in:
Ewan Mellor
2010-08-24 00:18:22 +00:00
committed by Tarmac

View File

@@ -29,6 +29,8 @@ import subprocess
import socket
import sys
from twisted.internet.threads import deferToThread
from nova import exception
from nova import flags
@@ -148,3 +150,9 @@ def isotime(at=None):
def parse_isotime(timestr):
return datetime.datetime.strptime(timestr, TIME_FORMAT)
def deferredToThread(f):
def g(*args, **kwargs):
return deferToThread(f, *args, **kwargs)
return g