<!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:394b0459-dd10-42fb-a1c9-2e70066eeb43@gmail.com">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:python-win32@python.org">python-win32@python.org</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>