Import2 scripting function causes Audacity to crash

Writing a python script to do some batch processing for work, running MacOS Mojave (10.14.3) and Audacity 3.0.0.

I’ve adapted the code and can see that the pipe write and read works fine; using the do_command() that prints a Send >>> and Rcvd <<< in the terminal, i’ve got the following lines in my main for-loop function:

do_command('Import2: Filename="{wav_path}"')
do_command('SetProject: Rate=8000')
# -- renaming functions here --
do_command('Export2: Filename="{new_wav_path}"')

When i run the code in terminal, i see the Import2 function returns a ‘Rcvd: <<< BatchCommand finished: Ok’, and a dialog box quickly pops up on Audacity before it abruptly crashes with none of the standard Apple crash dialog box. The rest of the script lines run in terminal - the command to set the project rate and bounce the file sends out into the ether with the ‘BatchCommand finished: Ok’ verifying that at least the code ran ok.

Every i reopen Audacity, the recovery dialog box pops up and i can reopen the crashed session; the file has actually successfully imported in, however the sample rate remains unchanged, and there is no bounced audio obviously. Frustratingly, the log doesn’t reflect the crash, and only starts from when Audacity is reopened, so I can’t see what exactly the issue is.

What am i missing here?

Try stepping through your script interactively so that you can see which step causes the problem (for example, prompt for a key press before each command).

Just checked through the Mac OS system log, and found this line when audacity crashes: ‘Service exited due to SIGPIPE’. Still trying to find out what this means, looking at another forum maybe it has something to do with macOS deleting the temp files that the pipe is running through for some reason?

Do you think this error could be caused by python sending a message to Audacity after Audacity has crashed ?