Will this work with a generator, and would it be possible to resume retrying from the failed state in a generator, not from the beginning?