Python API editor frames

Hi all,
I have some 3D environment in which I need to change the viewport position and take high-res screenshots.
The following commands work nicely when executed one-by-one:
But when trying to run several of those in a script, only the last command of each kind is being executed (and the is_task_done() always returns “False” during the script’s runtime).

I have scoured the net and API reference for days now, and I understand that when running a python script then the entire script is being executed in one editor frame (or tick), and the commands I want need to be run in consecutive frames, as depicted in the link below, for example:

My scene is completely static, and I don’t mind waiting as many frames as needed. What I couldn’t figure out is how do I wait for the next frame without exiting my script? Or how do I “tick” the editor from within it? The keywords are too generic (that is, if “frame” or “tick” are even the right terminology) and I can’t seem to find what I need in search or google.

I would be ever grateful for any pointing towards the right direction.
Many thanks, Tim.

The code in the above link worked for me.

@Tim_Stevens did you ever get this working? The link that darkczar pointed you to is dead but hopefully you remember what you did? I know this is really old, but I have the same issue.