[python-win32] Python service hangs in Dispatch when frozen with py2exe

Mark Hammond skippy.hammond at gmail.com
Fri May 28 08:34:50 CEST 2010


On 25/05/2010 11:27 AM, Don Dwiggins wrote:
> There's a good hint there. I've got all my imports listed at the top of
> the file. I do know that, when using the source, the file is read twice
> -- once from the command line by the usual Python interpreter, and once
> by PythonService; it must be different, though, when the compiled .exe
> is run both to install and to start the service. I can't quite use the
> hint to figure out why it should fail when I do an explicit CoInitialize
> at the start of a thread.

By "fail" here you mean "hang" right?

The object model semantics are tricky - if the object says it only 
supports single or apartment threading, COM is likely to marshal to the 
main thread regardless of how the thread initializes COM.

What is your main thread doing?  Can you make it run a message loop to 
test (ie, call pythoncom.PumpMessages() in that main thread?)

> I think (not sure) that the point where it hangs is always in
> pythoncom.new (for all permutations), where it's getting the OLE object
> to be wrapped. The question is, where in that function could it hang up
> waiting for something to happen?

In the underlying call to COM's CoCreateInstance.  I can't think of 
*why* that could happen though...

HTH,

Mark


More information about the python-win32 mailing list