[python-win32] Creating COM objects in a new process
Aviv Bergman
bergmana at gmail.com
Mon Feb 26 04:12:29 EST 2024
Hi
I'm trying to create several COM objects, each in a new process, but it
seems DispatchEx is reusing the existing COM server process, is there
any way to force creating new objects in a new process?
I'm using a python COM server, minimal example attached
Thanks
Aviv
---------
import os
import pythoncom
class CTest:
_reg_progid_ = "STO.test"
_reg_clsid_ = "{13704826-80EC-4205-ADCE-ADBE5B741731}"
_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
_public_methods_ = ["test"]
def __init__(self):
pass
def test(self):
return "process = " + str(os.getpid())
if __name__ == "__main__":
import win32com.server.register
win32com.server.register.UseCommandLine(CTest)
>>> import win32com.client
>>> o1 = win32com.client.DispatchEx("STO.test")
>>> o2 = win32com.client.DispatchEx("STO.test")
>>> o1.test()
'process = 26764'
>>> o2.test()
'process = 26764'
>>>
More information about the python-win32
mailing list