I have a script where I reference in a file, transfer some data from the reference to the nodes in the scene, and then unreference the file. I noticed that the script was running slowly. Depending on the scenes I used, it would hang for anywhere from 44 to 128 seconds. After some digging, I figured out that it stalls on the line:
cmds.file(removeReference=True, referenceNode=myRefNode)
Here's the weird thing: If I comment out that line, the script runs quickly. If I then run just that line through the Script Editor, it removes the reference quickly. No stalling.

I've been trying a few different things to avoid the stall, but no luck so far. Does anyone have any ideas? Has anyone seen anything like this before?