Avoid running code that uses logging in a thread

Fixes bug 946687

This avoids problems with code that uses logging from running in a thread
which isn't necessary for unit tests anyway.

Change-Id: I9c296c3c46317c9aaba7f1a92cd565a35682ce23
This commit is contained in:
Johannes Erdfelt
2012-03-06 16:43:30 +00:00
parent 4a4dbc6fe1
commit 8a2e933f77

View File

@@ -18,6 +18,8 @@
import json
import random
from eventlet import tpool
from nova.virt import xenapi_conn
from nova.virt.xenapi import fake
from nova.virt.xenapi import volume_utils
@@ -67,6 +69,11 @@ def stubout_session(stubs, cls, product_version=None, **opt_args):
product_version = (5, 6, 2)
stubs.Set(xenapi_conn.XenAPISession, 'get_product_version',
lambda s: product_version)
# NOTE(johannes): logging can't be used reliably from a thread
# since it can deadlock with eventlet. It's safe for our faked
# sessions to be called synchronously in the unit tests. (see
# bug 946687)
stubs.Set(tpool, 'execute', lambda m, *a, **kw: m(*a, **kw))
def stub_out_get_target(stubs):