Re: Creating COM objects in a new process
Mark Hammond <[email protected]> Mon, 26 Feb 2024 10:24:51 -0500
| Newsgroups | gmane.comp.python.windows |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--===============3319074297933535051==
Content-Type: multipart/alternative;
boundary="------------0j0ziuJGDgEr1r9kZ1SGjbCm"
Content-Language: en-US
This is a multi-part message in MIME format.
--------------0j0ziuJGDgEr1r9kZ1SGjbCm
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
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
> [email protected]
> https://mail.python.org/mailman/listinfo/python-win32
--------------0j0ziuJGDgEr1r9kZ1SGjbCm
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I'm not aware of anything, other than arranging for the existing
process to terminate.</p>
<p>Cheers,</p>
<p>Mark<br>
</p>
<div class="moz-cite-prefix">On 2024-02-26 4:12 a.m., Aviv Bergman
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:[email protected]">Hi
<br>
<br>
<br>
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?
<br>
<br>
<br>
I'm using a python COM server, minimal example attached
<br>
<br>
Thanks
<br>
Aviv
<br>
<br>
---------
<br>
<br>
import os
<br>
import pythoncom
<br>
<br>
class CTest:
<br>
_reg_progid_ = "STO.test"
<br>
_reg_clsid_ = "{13704826-80EC-4205-ADCE-ADBE5B741731}"
<br>
_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
<br>
_public_methods_ = ["test"]
<br>
<br>
def __init__(self):
<br>
pass
<br>
<br>
def test(self):
<br>
return "process = " + str(os.getpid())
<br>
<br>
<br>
if __name__ == "__main__":
<br>
import win32com.server.register
<br>
win32com.server.register.UseCommandLine(CTest)
<br>
<br>
<br>
>>> import win32com.client
<br>
>>> o1 = win32com.client.DispatchEx("STO.test")
<br>
>>> o2 = win32com.client.DispatchEx("STO.test")
<br>
>>> o1.test()
<br>
'process = 26764'
<br>
>>> o2.test()
<br>
'process = 26764'
<br>
>>>
<br>
_______________________________________________
<br>
python-win32 mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<br>
<a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/python-win32">https://mail.python.org/mailman/listinfo/python-win32</a>
<br>
</blockquote>
</body>
</html>
--------------0j0ziuJGDgEr1r9kZ1SGjbCm--
--===============3319074297933535051==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32
--===============3319074297933535051==--