So I was able to recreate the error by running the command in a thread. So I would double check to see if that is what is happening, and you can always wrap the cmd in maya.utils.executeDeferred or maya.utils.executeInMainThreadWithResult to push it back onto the main thread if this turns out to be the culprit.
that is interesting and good to know, but the script that threw that error doesn’t use threading, although the ls command is getting called when a UI needs to update itself based on a scriptjob.
Weird. I’ve had some of my MSceneMessage callbacks cause some errors similar to threading ones, event when I wasn’t explicitly using threading.
So I wonder if scriptJobs sometimes pull the same crap without telling us.
Also looks like folks have bumped into this before link.
Might be worth wrapping it in one of the defer execution functions to see if it avoids the error.
ive hit this before, but never found a good solution. It had to do with threading, but i think there was an error above it and this was just what happened to leak through. Just empathy from me