问题
I'm connecting to MS Word by win32com.client.Distpatch function and on the second request i've got error: 'CoInitialize has not been called.' I've found this topic:
http://www.velocityreviews.com/forums/t328097-coinitialize-error-when-using-adodbapi.html
and got that I have to call of CoInitialize in new thread. So question is where to call CoInitialize function in pyramid.
回答1:
So i added call of CoInitialize in function:
@subscriber(NewRequest)
def new_request_subscriber(event):
import pythoncom
pythoncom.CoInitialize()
and works without exception.
来源:https://stackoverflow.com/questions/12230240/how-to-use-python-and-windows-com-in-pyramid-threads