A simple function to run async code with sync syntax using generators.