Wait for RE Manager to switch to idle or paused state. See the documentation for wait_for_idle API.
idle
paused
wait_for_idle