如何使用python和windows com在金字塔(线程)? [英] How to use python and windows com in pyramid (threads)?

查看:177
本文介绍了如何使用python和windows com在金字塔(线程)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过win32com.client.Distpatch函数连接到MS Word,在第二个请求我有错误:'CoInitialize没有被调用'
我发现这个主题:

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

并得到我必须打电话的CoInitialize在新线程。
所以问题是在金字塔中调用CoInitialize函数的位置。

and got that I have to call of CoInitialize in new thread. So question is where to call CoInitialize function in pyramid.

推荐答案

/ p>

So i added call of CoInitialize in function:

@subscriber(NewRequest)
def new_request_subscriber(event):
    import pythoncom
    pythoncom.CoInitialize()

并且无异常。

这篇关于如何使用python和windows com在金字塔(线程)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆