“cmd.sync” is an API-only function which waits until all current commmands have been executed before returning. A timeout can be used to insure that this command eventually returns.
cmd.sync(float timeout=1.0,float poll=0.05)
def sync(timeout=1.0,poll=0.05):