Multithreaded COM server problem...

John Lull jl at
Sun Jan 11 08:48:09 CET 2004

Mark Hammond <mhammond at> wrote (with possible deletions):

> John Lull wrote:
> > I'm writing a multithreaded COM server to manage a pool of hardware resources.
> > All objects are designed to be thread-safe, and I've set sys.coinit_flags to
> > COINIT_MULTITHREADED before importing pythoncom.
> Note that this flag is effeectively ignored for the server.  Objects are 
> created in the same "apartment" as their creator.  This, the code 
> implementing your object need not specify this, but the code *creating* 
> the object must.  This is what determines the appartment.
> COM threading rules are complex, but "Python Programming on Win32" (1/2 
> by me :) covers these rules in words I would have trouble finding again :)

It covers threading rules for in-process servers pretty thoroughly.

Unfortunately, this one has to be a local server since it's providing shared
access to a pool of hardware devices from multiple distributed clients. I've
carefully reviewed chapters 5 & 12, and appendix D, and wasn't able to find
anything addressing threading models in the local server in detail. If I've
missed something, I'd be grateful for any additional hints. 



More information about the Python-list mailing list