Gracefully recovering from error in automation API and continuing capture

Hello,
Firstly let me say my thanks for automation API, I have a great time working with Saleae in this way :heart:

In my use case I need to perform very long Saleae capture. I expect, and I am fine with this, to encounter errors on the way. When error occurs I’d like to save the capture and start anew. It works fine apart from capture.close() in this snippet:

while CaptureEndCondition:
  capture = manager.start_capture(...)
  try:
    capture.wait()
  except (DeviceError, OutOfMemoryError) as e:
            # Handle the error
  # Save the capture
  try:
    capture.close()
  except SaleaeError:
    pass

I don’t really understand how Logic works under the hood and how it stores temp data, hence my question.
Is calling close() on capture that raised the SaleaeError legal? Does it properly tidy up data? If so, why does it raise the same error again raised by wait(), and is it safe for me to ignore the SaleaeError raised by close()?

@GregoryLakewood Sorry for the late reply! We had some folks out of office during the past week.

We unfortunately don’t have a great way of handling errors while a capture is ongoing using our Automation API. This is something we definitely want to tackle head-on at some point.

Our general suggestions around recording for long periods of time is summarized below. Could a strategy like that work out for you?

Hey,

thanks for your replay, it is holiday season for us also :smiley:
After a few tests I can say that all works well, following your guidelines from article as well as handling the exception in the manner I described.
It just strikes me that I am supposed to handle the exception twice - once in capture.wait() and once when calling capture.close(), it looks like bad code on my behalf. Also I am handling general SaleaeError which is not recommended by you.
I smells like it could cause some problems for example not clearing temp files or cache properly.

I will continue to use API and look forward to potential updates!

1 Like