From 8a2e933f77156cf77259bc460936ed9122bfcc29 Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Tue, 6 Mar 2012 16:43:30 +0000 Subject: [PATCH] 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 --- nova/tests/xenapi/stubs.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py index 511bcdb0..77557276 100644 --- a/nova/tests/xenapi/stubs.py +++ b/nova/tests/xenapi/stubs.py @@ -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):