Automation export issue: session can´t be closes while export

analyzer = automation.Manager.connect(port=10430)
with analyzer.start_capture(device_id, device_cfg, capture_cfg) as capture:
   capture.wait()
   if not path_for_logs.exists():
       path_for_logs.mkdir(parents=True, exist_ok=True)
   try:
       capture_filepath = path_for_logs / "capture.sal"
       capture.save_capture(capture_filepath.absolute().as_posix())
       capture.export_raw_data_binary(path_for_logs.absolute().as_posix())
   except Exception as e:
       logger.error("Captures could not be exported:%s", e)

# next capture
with analyzer.start_capture......

I’m using an implementation similar to what I’ve shown above. My problem is that when I run multiple captures after each other. I get an error message in the Logic 2 UI telling me that I can’t close a capture while exporting files. From that point on, the entire UI flickers and feels glitchy while it continues to work. Is there anything else I can do except waiting a second or two at the end of each capture? It would make me feel better if the exit waited until the export was complete.

@dominic.styblo Sorry for the trouble with that! Can you try exporting the raw data first before saving your capture?

I see the same order followed in 2 example scripts that we provide (in particular, the script at the bottom of the 2nd link shows an immediate call to close the capture after saving the capture, without any delays implemented):

Also, can you give a rough approximation as to how long your captures are, how many channels are enabled, and what kind of data is being saved/exported?

@dominic.styblo I wasn’t able to reproduce the error message you described below in my attempt to run multiple captures one after another in one script (saving/exporting data after each capture). I’ve attached the script I used to test this below.

saleae_example_multi_capture.py (2.6 KB)

  1. Are you able to share a Python script that can reproduce this error? I’d like to try running it on my end. Perhaps your provided script is able to trigger some kind of edge case that I’m not able to reproduce.
  2. Can you share an image of the error message you get in the Logic 2 UI?

By the way, I’d like to share a sample script below that can help with using a separate thread to save, export and close the capture while the next capture is already starting. Our sample here demonstrates how to do it:

In summary, this would allow you to start your next capture while you are saving/exporting the previous capture, thereby reducing the delay between captures.