Fix COM thread model issue

The following issue happens when trying to extend volumes using VDS:

OSError: [WinError -2147417850] Cannot change thread mode after it
is set

sys.coinit_flags needs to be set before importing pythoncom.

Change-Id: I83877219b9589d9c174fd3a245b644350ea6310a
Closes-Bug: #1787659
This commit is contained in:
Alessandro Pilotti 2018-08-18 00:25:20 +03:00
parent b2f738236d
commit 0d04300138
1 changed files with 2 additions and 1 deletions

View File

@ -18,8 +18,9 @@ import sys
if struct.calcsize("P") == 8 and sys.platform == 'win32':
# This is needed by Nano Server.
# Set COINIT_MULTITHREADED only on x64 interpreters due to issues on x86.
# sys.coinit_flags needs to be set before importing pythoncom
sys.coinit_flags = 0
import pythoncom
sys.coinit_flags = pythoncom.COINIT_MULTITHREADED
pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)
from oslo_log import log as oslo_logging