[python-win32] Creating COM objects in a new process
Mark Hammond
mhammond at skippinet.com.au
Mon Feb 26 10:24:51 EST 2024
I'm not aware of anything, other than arranging for the existing process
to terminate.
Cheers,
Mark
On 2024-02-26 4:12 a.m., Aviv Bergman wrote:
> 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'
> >>>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/python-win32/attachments/20240226/1bffda99/attachment.html>
More information about the python-win32
mailing list