0

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

Jasurbek
  • 2,946
  • 3
  • 20
  • 37

1 Answers1

0

Ok at the moment the workaroud is to re-dispatch CANalyzer in the thread when the test time is > 400 s. Anyway if someone finds a better solution I'd be glad to read it !