OK, I have more information that may help. Looking into the code invoked by IA.clsAuthorizeBatch(), I've found that the hangup occurs in the call to pythoncom.new in CoClassBaseClass in win32com\client\__init__.py.

Interestingly, if I run the code in the "main" Twisted thread, it executes without a problem (this is running the source, with py2exe out of the picture). If I run it in a subthread (using Twisted's DeferToThread) it hangs in the following call:

oo = pythoncom.new(IA.clsAuthorizeBatch.CLSID)

.. where IA is the gen_py file, as before. The COM DLL is implemented in VB with a single threaded model (although I've tried making it apartment threaded as well).

I can't go any deeper at the python level, since pythoncom is a DLL.

As before, any advice appreciated ...

I wrote previously:
I'm developing a Python service under Win XP with Python 2.5 (the service is built on Twisted's XMLRPC server). For delivery to production, I "compile" it with py2exe. It's been running fine, but I've hit a snag.

I've written new code to access a COM object (in a DLL); the code I've written does works successfully as long as I'm running the source under PythonService.

The compiled version, however, hangs up in the call to Dispatch to get the COM object. I've put in debugging log entries all through the relevant section of code, and it's clear that it simply never returns from the Dispatch call. I've tried EnsureDispatch as well, and more recently the following code:

  iab = IA.clsAuthorizeBatch()
  auth = DispatchEx(iab.CLSID)

... where I've imported the gen_py module under the name IA (I've copied the module file to the same folder as the service, so there's no issue with py2exe or the executable not being able to find it). In this case, the hangup occurs in the first statement. I've tried running the code with and without wrapping it in CoInitialize/Couninitialize.

I've run out of things I can think of to try, or even to get a hint of what might be getting hung up. One last bit of data: looking at the process in Process Explorer, I see that it's very busy for several seconds (about 50% CPU), then goes quiet.

Any good words appreciated,

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to