Lightweight function to retry an async job until the job success or stop after a maximum number of tries