From oudouxin at gmail.com Wed Feb 7 16:03:39 2024 From: oudouxin at gmail.com (Wuping Xin) Date: Wed, 07 Feb 2024 21:03:39 +0000 Subject: [python-win32] pywin32 incompatible with Python 3.12 In-Reply-To: References: Message-ID: Python 3.12 removed the module 'imp', but pyscript.py still relies on 'import imp' - this will lead to: ModuleNotFoundError: No module named 'imp' pyscript.py", line 213, in InitNew import imp ModuleNotFoundError: No module named 'imp' Solutions? Wuping From mhammond at skippinet.com.au Wed Feb 7 16:56:03 2024 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 7 Feb 2024 16:56:03 -0500 Subject: [python-win32] pywin32 incompatible with Python 3.12 In-Reply-To: References: Message-ID: <378d3da3-d4a2-4581-8f94-db61256956e3@skippinet.com.au> pywin32 is overdue a release, compounded by the fact I no longer have a Windows machine available. As noted in the readme, github actions to create "artifacts" on some pushes, so, eg, https://github.com/mhammond/pywin32/actions/runs/7713784334/artifacts/1206054711 will have a recent wheel for all supported versions including 3.12 which will not have that error. HTH, Mark On 2024-02-07 4:03 p.m., Wuping Xin wrote: > Python 3.12 removed the module 'imp', but pyscript.py still relies on > 'import imp' - this will lead to: ModuleNotFoundError: No module named > 'imp' > > pyscript.py", line 213, in InitNew > import imp > ModuleNotFoundError: No module named 'imp' > > Solutions? > > Wuping > _______________________________________________ > 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: From alexurbina0119 at gmail.com Tue Feb 13 22:20:51 2024 From: alexurbina0119 at gmail.com (Alexander Urbina) Date: Tue, 13 Feb 2024 21:20:51 -0600 Subject: [python-win32] OLE Error during dispatch Message-ID: Hi All, So I'm currently having an issue with pywin32, I keep getting this OLE error: Error: (-2146233036, 'OLE error 0x80131534', None, None), is there anyone who is familiar with how to solve this issue or knows what the root cause is? I'm trying to connect to an application called INCA from ETAS but I keep getting this error. Any help would be appreciated thanks! Best, A.U import win32com.client import os import sys def start_inca_measurement(): try: # Create a COM object inca_app = win32com.client.Dispatch("Inca.Inca.7.4") -------------- next part -------------- An HTML attachment was scrubbed... URL: From bergmana at gmail.com Mon Feb 26 04:12:29 2024 From: bergmana at gmail.com (Aviv Bergman) Date: Mon, 26 Feb 2024 20:12:29 +1100 Subject: [python-win32] Creating COM objects in a new process Message-ID: <394b0459-dd10-42fb-a1c9-2e70066eeb43@gmail.com> 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' >>> From mhammond at skippinet.com.au Mon Feb 26 10:24:51 2024 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 26 Feb 2024 10:24:51 -0500 Subject: [python-win32] Creating COM objects in a new process In-Reply-To: <394b0459-dd10-42fb-a1c9-2e70066eeb43@gmail.com> References: <394b0459-dd10-42fb-a1c9-2e70066eeb43@gmail.com> Message-ID: <71e75e18-eb08-46e2-bfc9-316f7290cf70@skippinet.com.au> 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: From oudouxin at gmail.com Mon Feb 26 12:57:46 2024 From: oudouxin at gmail.com (Wuping Xin) Date: Mon, 26 Feb 2024 17:57:46 +0000 Subject: [python-win32] Creating COM objects in a new process In-Reply-To: References: Message-ID: This is related the COM instance model implemented on the COM server side, not on the client side. Specifically, in the start-up code of the COM server application, there should be a call to CoRegisterClassObject(CLSID, pUnk, dwClsContext, flags, &dwRegister). The key point is the fourth parameter ?flags?. It determines during run-time whether the COM server exe can be started as single instance or multiple instances. See this MSDN for more details: https://learn.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-coregisterclassobject?redirectedfrom=MSDN Bottom line, this depends on the COM server implementation, not something the client side can control. Wuping ------ Original Message ------ >Date: Mon, 26 Feb 2024 20:12:29 +1100 >From: Aviv Bergman >To: python-win32 at python.org >Subject: [python-win32] Creating COM objects in a new process >Message-ID: <394b0459-dd10-42fb-a1c9-2e70066eeb43 at gmail.com> >Content-Type: text/plain; charset=UTF-8; format=flowed > >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' > >>> > > >------------------------------ > >Message: 2 >Date: Mon, 26 Feb 2024 10:24:51 -0500 >From: Mark Hammond >To: Aviv Bergman , python-win32 at python.org >Subject: Re: [python-win32] Creating COM objects in a new process >Message-ID: <71e75e18-eb08-46e2-bfc9-316f7290cf70 at skippinet.com.au> >Content-Type: text/plain; charset="utf-8"; Format="flowed" > >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: > >------------------------------ > >Subject: Digest Footer > >_______________________________________________ >python-win32 mailing list >python-win32 at python.org >https://mail.python.org/mailman/listinfo/python-win32 > > >------------------------------ > >End of python-win32 Digest, Vol 247, Issue 3 >******************************************** From bergmana at gmail.com Tue Feb 27 04:22:43 2024 From: bergmana at gmail.com (Aviv Bergman) Date: Tue, 27 Feb 2024 20:22:43 +1100 Subject: [python-win32] Creating COM objects in a new process In-Reply-To: References: Message-ID: <174ad59d-36c4-4e96-b323-0473ffd65a15@gmail.com> Thanks Wuping As I also implement the COM server, this really helped finding the solution - I had to re-implement win32com.server.localserver.serve and pass flags=pythoncom.REGCLS_SINGLEUSE | pythoncom.REGCLS_SUSPENDED