It seems that OmniFocus frequently syncs while the script is running. Their technical support pointed out that will autosave (Boolean) can be used to disable sync at the beginning and then re-enable it at the end to avoid this thrashing and speed things up.