I have a python code that starts CANalyzer and stops it after n seconds (defined by the user with a tkinter GUI) inside a timer thread. Here is the code:
pythoncom.CoInitialize()
CANalyzer = win32com.client.Dispatch('CANalyzer.Application')
self.CAN_id = pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch, CANalyzer)
then in the thread:
def timer_Stop_reply(CAN_id):
pythoncom.CoInitialize()
CAN = win32com.client.Dispatch(
pythoncom.CoGetInterfaceAndReleaseStream(CAN_id, pythoncom.IID_IDispatch)
)
CAN.Measurement.Stop()
self.stopped_DSE=1
pythoncom.CoUninitialize()
print('\n=== Stopping Trace ===')
Unfortunately, there is a sort of timeout after 400 s, in fact, I get this error (-2147417848, 'The object invoked has disconnected from its clients.', None, None)
. How can I avoid this problem? Is there something like a keep alive? I need to run CANalyzer for more than 10 min in my test so this error is really annoying.
Thanks